RegEx


 

RegEx>pattern,text,easypatterns,matches_array,num_matches,replace_flag[,replace_string,replace_result]

 

Performs the regular expression in pattern on text, returning the number of sub matches in num_matches and the text found in matches_array.  RegEx is compatible with the Perl 5.10 regular expression syntax using the PCRE library.

 

matches_array is the name of a variable to store the results.  The first match is stored in matches_array_1, the second in matches_array_2, etc.

 

To perform a replacement set replace_flag to 1 and specify the replacement string in replace_string and the return variable in replace_result.   Otherwise set replace_flag to 0.

 

By setting easypatterns to 1 pattern can use EasyPatterns syntax.  EasyPatterns uses an english-like structure to simplify the use of regular expressions.  See the EasyPatterns Reference.

 

Abbreviation: RGX

 

Examples

 

//Find an IP address:

Let>text=This is an IP address: 192.168.10.42

Let>pattern=(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b)

RegEx>pattern,text,0,matches,num,0

MessageModal>matches_1

 

//Find an IP address with EasyPatterns:

Let>text=This is an IP address: 192.168.10.42

Let>pattern=[IPAddress]

RegEx>pattern,text,1,matches,num,0

MessageModal>matches_1

 

//Replacement:

Let>text=My Email Address: [email protected]

Let>pattern=[EmailAddress]

RegEx>pattern,text,1,matches,num,1,[email protected],text

MessageModal>text