String Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > String commands >

String Operations

GRR. - Get Regular Replace

Previous Top Next


MiniRobotLanguage (MRL)

 

GRR. Command

Get Regular Replace

 

 

Intention

 

GRR. Enables you to replace Parts from Strings which match a regular expression.

 

What is it really good for?

 

Using "regular expressions" you can do things that would be difficult to realize in  other ways. Take our example. You want to replace all e-mail addresses in a document automatically with the term "[e-mail]. Sounds difficult?

 

Is easy:

 

' Use Regular Expression to replace an e-mail adress

: $$NUM=2

: $$MAC=please send an email to info@it-berater.org

: $$MSK=([a-z0-9._/+-]+)(@[a-z0-9.-]+)

: $$REP=[E-Mail]

 

DBP.Before:

DBP.$$MAC

 

GRR.$$NUM,$$MAC,$$MSK,$$REP

 

DBP.After Replace

DBP.$$MAC

END.

 

See Regular Expression

 

 

Syntax

 

GRR.[P1],P2,P3,P4

 

 

Parameter Explanation

 

P1  -  (optional) NUM/VAR

-       Start of Stringscan.

-       This can be a Variable containing a number or a number.

 

 

P2  - VAR

-       Main String. Can only be a Variable of any Type.

-       Non-String-Types will be converted to a  Textstring.

 

P3  - VAR Regular Expression. This  Variable contains the regular Expression.

 

P4 - VAR

 

P2 and P3 must be Variables.

You cannot just write the Regular Expression in the Parameter-Field as 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 replace an e-mail adress

: $$NUM=2

: $$MAC=please send an email to info@it-berater.org

: $$MSK=([a-z0-9._/+-]+)(@[a-z0-9.-]+)

: $$REP=[E-Mail]

 

DBP.Before:

DBP.$$MAC

 

GRR.$$NUM,$$MAC,$$MSK,$$REP

 

DBP.After Replace

DBP.$$MAC

END.

 

 

 

Remarks

 

-

 

 

Limitations:

 

-

 

See also:

 

    1.5.2 Working with Text-Strings

    VAR. - Variable Set Value/Clear

    GRE. - Get Regular Expressio

    IVS. / NVS. - If-Variable-String

    GSS. - GetSplitString

    ! STR. - String Command

    GES. - Get-Extracted-String

    SBD. - String between Delimiter

    SBM. - String between Delimiter-Multiple

    FEM. - For Each Member

    LEN. - Length-of-String