JSRegEx (open)
JavaScript-like regular expression
Syntax
LOADLIB "wh::regex.whlib";
OBJECTTYPE JSRegEx
Constructor
- MACRO NEW(STRING pattern, STRING flags)
Create a JavaScript-like regular expression object
Variables
- BOOLEAN global
If set to TRUE, search from lastindex, and set it after the match
- BOOLEAN ignorecase
If set to TRUE, do a case insensitive match
- INTEGER lastindex
The position at which the next search will start, automatically updated after exec or test
- BOOLEAN multiline
If searches may span multiple lines (i.e. if "^" may occur after a "\n" and "$" before a "\n")
Properties
- PROPERTY source
The source pattern
Functions
- RECORD ARRAY FUNCTION Exec(STRING input)
Search the next match of the regular expression within an input string
- STRING FUNCTION Replace(STRING input, STRING replacewith)
Replace every occurrence of a regular expression
- STRING FUNCTION ReplaceCallback(STRING input, FUNCTION PTR replacefunc)
Replace every occurrence of a regular expression by the result of a callback function
- BOOLEAN FUNCTION Test(STRING input)
Test if a match of the regular expression is present within an input string