RoboTask User's Guide
Keyword Index
Home page



IconQuick Start Guide
IconSeveral practical recommendations
IconMenus
IconActions
IconTriggering Events
IconAppendix
IconOther software

© 2004-2017 Neowise.com

RegExp Loop

Top  Previous  Next

Using RedExp Loop you can find all entries of a phrase you seek in a text and process them in a loop. A phrase mask is specified by a regular expression. The search result of every iteration is saved in a variable as a standard comma-separated string. The whole sought-for phrase is always a zero element. The following elements contain sub-expressions if they are present in a regular expression. Sub-expressions are a part of phrase which is put into parentheses. A sub-expression number is the ordinal number of an opening parenthesis if you read the expression from the left to the right.

For example, the regular expression for search of links addresses in HTML text is:

<a\s+href\s*=\s*"([\S]*)">\s*(<?[^<>]*>?)\s*</a>

This regular express contains two sub-expressions:

- The link address

- The link description

You can put the modifier which is not a sub-expression in the beginning of expression: (?i). This combination means the search has to be done with no account taken to the register. The symbol ? in modifier always follows an opening parenthesis but goes before a closing one.

For example: (?im). Modifiers can be in any place of a regular expression. See below the description of search modes and corresponding modifiers.

 

General

RegExpLoop1

 

External Text

Input the name of the text file in which the search will be implemented. Variables can be used.

Specified Text

In this field specify the text in explicit form on which you want to search. You can use variables.

Pattern (Regular Expression)

Input a regular expression (a phrase mask) for the search in a text. You can find description of regular expression syntax and manuals on the site http://www.regular-expressions.info/

Save Found Expression to Variable

Input the name of a variable in which you want to save the search result. If the search-for phrase is found, the search result will be saved in the variable like a standard comma-separated string. To extract a separate element you need to refer to the variable as an array.

For example:

{MyVar(0)}

{MyVar(1)}

Etc.

The zero element of array is always the search-for phrase as a whole.

The next array elements are sub-expressions in the search-for phrase which are highlighted in the regular expression by parenthesis (certainly, if there are such). If you didn’t specify any sub-expressions in the regular expression, the resultant array would consist of a single element, which is zero element.

 

Additional options

RegExpLoop2

 

Case Insensitive

Tries to match the regex without paying attention to case.  If set, 'Bye' will match 'Bye', 'bye', 'BYE' and even 'byE', 'bYe', etc.  Otherwise, only 'Bye' will be matched.  Equivalent to (?i) modifier. The modifier (?-i) switches off the mode case insensitive.

MultiLine

The ^ (beginning of string) and $ (ending of string) regex operators will also match right after and right before a newline in the Subject string.  This effectively treats one string with multiple lines as multiple strings.  Equivalent to Perl's (?m) modifier. The modifier (?-m) switches off the mode multiline.

Single Line

Normally, dot (.) matches anything but a newline (\n).  With Single Line mode, dot (.) will match anything, including newlines.  This allows a multiline string to be regarded as a single entity.  Equivalent to Perl's (?s) modifier. The modifier (?-s) switches off the mode single line.

Note that MultiLine and Single Line can be used together.

Extended Style

Allow regex to contain extra whitespace, newlines and Perl-style comments, all of which will be filtered out.  This is sometimes called "free-spacing mode".

Anchored

Allows the regex to match only at the start of the subject or right after the previous match.

Ungreedy

Repeat operators (+, *, ?) are not greedy by default (i.e. they try to match the minimum number of characters instead of the maximum).

No Autocapture

Is a non-capturing group, only named groups will be captured.

Save Offsets to Variables

If you want to determine positions of found expressions from the beginning of a text switch on this flag and input a variable name, the positions will be saved as a comma-separated string. A zero element - this is a position of a whole expression. The next elements are positions of subexpressions. The beginning of a text corresponds to the position 1.

Save Lengths to Variables

If you want to determine the lengths of found expressions (by symbols), switch on this flag and input the variable name. The lengths will be saved as a comma-separated string. A zero element is a length of a whole expression. The next elements are lengths of subexpressions.

 

 

note Related Topics

RegExp Replace

RegExp Match

RegExp COM object