The rgx module implements regular expressions. It supports words for compiling and matching regular expressions. The module uses the nfe module for the actual expression building and matching.
This module uses the following syntax: . Match any char [incl. newline] * Match zero or more + Match one or more ? Match zero or one | Match alternatives Group or subexpression Backslash characters: \. Character . \* Character * \+ Character + \? Character ? \| Character | \\ Backslash \r Carriage return \n Line feed \t Horizontal tab \e Escape \d Digits class: [0-9] \D No digits: [^0-9] \w Word class: [0-9a-zA-Z_] \W No word: [^0-9a-zA-Z_] \s Whitespace \S No whitespace All other backslash characters simply return the trailing character, but this can change in future versions.
include ffl/rgx.fs \ Create a regular expression variable rgx1 rgx-create rgx1 \ Compile a regular expression and check the result s" ((a*)b)*" rgx1 rgx-compile [IF] .( Expression succesfull compiled) cr [ELSE] .( Compilation failed on position:) . cr [THEN] \ Match case sensitive a test string s" abb" rgx1 rgx-cmatch? [IF] .( Test string matched) cr [ELSE] .( No match) cr [THEN] \ Create a regular expression variable on the heap rgx-new value rgx2 \ Compile a regular expression for matching a float number s" (\+|-|\s)?\d+(\.\d+)?" rgx2 rgx-compile [IF] .( Expression succesfull compiled) cr [ELSE] .( Compilation failed on position:) . cr [THEN] \ Match a float number s" -12.47" rgx2 rgx-cmatch? [IF] .( Float number matched) cr [ELSE] .( No match) cr [THEN] \ Free the variable from the heap rgx2 rgx-free