Core Function RegexUnescape
From Sputnik Wiki
RegexUnescape( <expression> )
Contents |
Description
Remove any escapes from regular expression characters.
RegexUnescape() takes a string and removes any backslash in front of every character that is part of the regular expression syntax.
Parameters
expression
The string to use.
Return Value
Success: Returns the escaped string.
Failure: Returns empty string and sets @Error.
Remarks
If an escaped character in the string is not a Regexp compatible character then an empty string will be returned unmodified and the @Error will be set.
Example
// Obviously using @"" is the best way use Regexp strings say @"(\w+)\s(\1)"; // Prints: (\w+)\s(\1) say RegexEscape(@"(\w+)\s(\1)"); // Prints: \(\\w\+\)\\s\(\\1\) say RegexUnEscape(RegexEscape(@"(\w+)\s(\1)")); // Prints: (\w+)\s(\1)
Using @Error
say RegexUnEscape(@"\m"); if(@Error) { say "There was an error parsing"; say @ErrorMsg; }