Share:
Developers » Scripting Code Samples » Validating Strings in a Script

PREVIOUS  |  NEXT

You can use Regular Expressions to validate strings in a script. Use the RegularExpressionManager to get an existing regular expression and validate it against a string, as shown in the following example:

def regexManager = resp.regex;
def validator = regexManager.getRegularExpression("testregexmanager");
out << validator.validate("11/11/2011"); 

The result will be true if the string is valid according to the referenced regular expression, false otherwise.