ValidateRegex
From GECK
A function added by the New Vegas Script Extender version 6.2.9.
Contents
Description
Tests whether the specified Regular Expression pattern is valid or not.
This is only useful to test regex that is dynamically retrieved from a file or other dynamic source. If the regex is known beforehand, consider using an online validator.
Possible return values are listed below:
Error_FailedToExtractArgs = -1, NoErrors = 0, Error_Collate = 1, Error_Ctype = 2, Error_Escape = 3, Error_Backref = 4, Error_Brack = 5, Error_Paren = 6, Error_Brace = 7, Error_Badbrace = 8, Error_Range = 9, Error_Space 10, Error_Badrepeat = 11, Error_Complexity = 12, Error_Stack = 13, Error_Unknown = 14
If an error occurs and outErrorStrVar is set to a valid string variable, then that string variable will be set to contain information explaining the nature of the error.
Syntax
(match:0/1) ValidateRegex regEx:string outErrorStrVar:string_var
Example
string_var sOutError = "" int iError = ValidateRegex "[" sOutError printvar iError ; Will print "5" (Error_Brack) printvar sOutError ; Will print a string explaining that the error is caused by mismatched brackets (missing closing bracket).
See Also
- sv_RegexMatch
- sv_RegexSearch
- sv_RegexReplace
- To test Regex expressions, consider using this website: Regex101