<< Click to Display Table of Contents >> Navigation: 3. Script Language > String commands > String Operations |
MiniRobotLanguage (MRL)
GRE. Command
Get Regular Expressions
Intention
Enables you to extract Parts from Strings or test if a string matches a regular expression.
What are regular expressions good for?
Ok, they are a challenge if you use them first time. But Challenges are something positive. Catch them. At the end of a challenge you will know yourself better - and you will have new abilities.
When you know about regular expressions, you can do things the easy way. Things, you would have never thought about before.
The following line will extract the E-Mail adress from the line.
' Use Regular Expression to extract an e-mail address
: $$NUM=2
: $$MAN=please send an email to info@it-berater.org
VAS.$$MSK=([a-z0-9._/+-]+)(@[a-z0-9.-]+)
' This will do the Job.
GRE.$$NUM,$$MAN,$$MSK
STS.DUMP
DMP.
END.
Syntax
GRE.[P1],P2,P3
Parameter Explanation
P1 - (optional) Start of Stringscan. This can be a Variable containing a number or a plain number.
P2 - VAR with Main String. Can only be a Variable.
P3 - VAR with Regular Expression. This Variable contains the regular Expression.
P2 and P3 must be Variables. You cannot just write the Regular Expression in the Parameter-Field because the $ and the | are special-characters in Regular Expressions.
Please note that for this command, you have to use the "," instead of the "|" to separate the Parameters.
Example
' Use Regular Expression to extract an e-mail address
: $$NUM=2
: $$MAN=please send an email to info@it-berater.org
VAS.$$MSK=([a-z0-9._/+-]+)(@[a-z0-9.-]+)
GRE.$$NUM,$$MAN,$$MSK
STS.DUMP
DMP.
END.
' Use Regular Expression to extract the value
VAS.$$MSK=\$[0-9.,]+
: $$MAN=Der Schuldbetrag ist $39.75 plus Steuern
GRE.$$NUM,$$MAN,$$MSK
STS.DUMP
DMP.
END.
Remarks
Limitations:
-
See also:
• 1.5.2 Working with Text-Strings
• VAR. - Variable Set Value/Clear
• IVS. / NVS. - If-Variable-String
• SBD. - String between Delimiter
• SBM. - String between Delimiter-Multiple