HELP: Regular expression for validation and/or replacement TYPE: OBJECT SYNTAX: REGEXP(PATTERN='str',REPLACE='str',NOCASE,MULTILINE,DOT4ALL,EXTENDED,NOCAPTURE,SUBALL,RPLONLY,FMTERR,IGNREC)
This object can be used to activate the validation and/or replacement of the content of a string. For this a Perl-compatible regular expression and optional a corresponding replacement string can be defined.
Writing regular expressions may seem like a daunting task if you never did so before. You can find a tutorial that will get you started quickly here:
https://www.regular-expressions.info/quickstart.html
Countless other tutorials and documentation for regular expressions can be found on the web. We recommend to consult these resources to familiarize yourself with regular expressions.
Advanced users can find the complete syntax documentation for writing regular expression patterns by following this URL:
https://www.pcre.org/current/doc/html/pcre2pattern.html
At write you can ignore all records without a successful match of the regular expression. In this case the unmatching lines will be skipped. By default a mismatch will result in a validation error. If the replace string defined, then the default will keep the data if no match found. In this case the IGNREC switch will skip all lines where no replacement are done. With the FMTERR switch you can enforce an error if no replacement done but a replacement string provided.
Several flags are supported to control the behavior of the validation or substitution process.
STRING: PATTERN='str' - Pattern of regular expression for matching
STRING: REPLACE='str' - Replacement string for substitution
SWITCH: NOCASE - Case insensitive matching
SWITCH: MULTILINE - '^' and '$' match start/end of line instead of start/end of whole string
SWITCH: DOT4ALL - Change '.' to match any character whatsoever, even a newline, which normally it would not match
SWITCH: EXTENDED - Makes parser ignore whitespace and '#' comments within the pattern (can be used for readability)
SWITCH: NOCAPTURE - Prevent the grouping metacharacters '()' from capturing
SWITCH: SUBALL - Match and replace repeatedly until all occurrences are replaced
SWITCH: RPLONLY - Only returns the replacement substrings
SWITCH: FMTERR - Return a format error if no match (stop if no replacement)
SWITCH: IGNREC - Remove every record that the regex does not match