Player APIs (BrightScript & Ja...
...
Object Reference
BrightScript Core Objects
roRegex
6min
this object allows the implementation of the regular expression processing provided by the pcre library the javascript equivalent is regexp() this object is created with a string to represent the matching pattern and a string to indicate flags that modify the behavior of one or more matching operations createobject("roregex", "\[a z]+", "i") the match string (in the example above, "\[a z]+" , which matches all lowercase letters) can include most perl compatible regular expressions found in the pcre documentation http //pcre org/ this object supports any combination of the following behavior flags (in the example above, "i", which can be modified to match both uppercase and lowercase letters) "i" case insensitive match mode "m" multiline mode the start line ("^") and end line ("$") constructs match immediately before or after any newline in the subject string they also match at the absolute beginning or end of a string "s" dot all mode, which includes a newline in the " " regular expression this modifier is equivalent to "/s" in perl "x" extended mode, which ignores whitespace characters except when escaped or inside a character class this modifier is equivalent to "/x" in perl ifregex ismatch(string as string) as boolean returns true if the string is consistent with the matching pattern match(string as string) as roarray returns an roarray of matched substrings from the string the entire match is returned in the form array\[0] this will be the only entry in the array if there are no parenthetical substrings if the matching pattern contains parenthetical substrings, the relevant substrings will be returned as an array of length n+1, where array\[0] is the entire match and each additional entry in the array is the match for the corresponding parenthetical expression replace(string as string, subset as string) as string replaces the first occurrence of a matching pattern in the string with the subset and returns the result the subset may contain numbered back references to parenthetical substrings example \> r = createobject("roregex", "(\d+)\s+(\w+)", "") \> ? r replace("123 abc", "word \2 number \1") \> word\ abc number 123 replaceall(string as string, subset as string) as string replaces the all occurrences of a matching pattern in the string with the subset and returns the result example \> r = createobject("roregex", "a", "i") \> ? r replaceall("abracadabra", "x") xbrxcxdxbrx split(string as string) as rolist uses the matching pattern as a delimiter and splits the string on the delimiter boundaries the function returns an rolist of strings that were separated by the matching pattern in the original string