REGEXP – Regular expression parser

Block SymbolLicensing group: ADVANCED
Qt SVG Document Exported by REXYGEN Studio text RUN MATCH cap cap1 cap2 cap3 cap4 cap5 cap6 cap7 cap8 REGEXP

Function Description
The REGEXP block implements the most common subset of regular expressions as known, for example, from the regex command in Perl or C#, or the grep command known from the command line of Unix operating systems.

Supported syntax is as follows:

  • (?i) …Must be at the beginning of the regex. Makes match case-insensitive
  • ^ …Match beginning of a buffer
  • $ …Match end of a buffer
  • () …Grouping and substring capturing
  • \s …Match whitespace
  • \S …Match non-whitespace
  • \d …Match decimal digit
  • \n …Match new line character
  • \r …Match line feed character
  • \f …Match form feed character
  • \v …Match vertical tab character
  • \t …Match horizontal tab character
  • \b …Match backspace character
  • + …Match one or more times (greedy)
  • +? …Match one or more times (non-greedy)
  • * …Match zero or more times (greedy)
  • *? …Match zero or more times (non-greedy)
  • ? …Match zero or once (non-greedy)
  • x|y …Match x or y (alternation operator)
  • \meta …Match one of the meta characters: ^$().[ ]*+?|\
  • \xHH …Match byte with hex value 0xHH, e.g. \x4a
  • [...] …Match any character from set. Ranges like [a-z] are supported.
  • [^...]…Match any character except the ones in set. Ranges like [a-z] are supported.

Examples

  • [0-9]+ …Finds first integer in input string (and puts it into cap output).
  • [-+]?[0-9]*\.[0-9]+([eE][-+]?[0-9]+)?…Find first real number in input string (and puts it into cap output).
  • ^\s*(.*?)\s*$ …Puts trimmed input string into cap1 output.
  • num\s*:\s*([0-9]*\.[0-9]*) …Expects input string in JSON format; find integer parameter num, and puts its value into cap1.

This block does not propagate the signal quality. More information can be found in the 1.4 section.

Input

text

String to parse

String

RUN

Enable execution

Bool

Parameter

expr

Regular expression pattern

String

nmax

Allocated size of string   0  65534

Long (I32)

bufmax

Parser internal buffer size (0 = autodetect)   0  10000000

Long (I32)

Output

MATCH

Pattern match flag

Bool

cap

Whole matching string

String

cap1..cap8

Captured string

String

2024 © REX Controls s.r.o., www.rexygen.com