Es regex matchformat

From EventScripts Community Encyclopedia


Overview

Syntax: es_regex matchformat <variable> <expression> <string> <formatstring>

Note: Command parameters are described inside the < and > characters. Optional parameters are contained within [ and ] characters.

Variation of this command that doesn't expand variables: es_xregex matchformat

Description

Compare the string with the regular expression, put the tokens into the formatstring and save the resultstring into variable


Parameters

  • variable - the name of the variable to store the resulting string in
  • expression - a regular expression/pattern to match against
  • string -- the string to compare with
  • formatstring -- string where tokens found with the regular expressions are put in.


Examples

es_xsetinfo myvar 0
es_xsetinfo mystring "!bet 1000 #ct"
es_regex matchformat myvar "!bet .* ([#][a-z]+)" server_var(mystring) "This is the first token: %1. This is the second token: %2."
 
// Will output into myvar: "This is the first token: 1000. This is the second token: #ct." 


Notes

  • Regular expressions are your friend. They're complicated like any good friend should be.
  • First available in v1.3 of EventScripts.
  • Warning: More tokens in the formatstring as in the regular expression will cause the engine and/or the computer to crash!


See also

blog comments powered by Disqus