Go to: Synopsis. Return value. Related. MEL examples.
int isValidString(string $string, string $regularExpression)
None
Variable Name | Variable Type | Description |
---|---|---|
$string | string | The name string to test. |
$regularExpression | string | The regular expression. |
// Regular expression does not allow spaces. // isValidString("Name1", "([a-zA-Z]+)([a-zA-Z0-9_])*"); // Will succeed. // Regular expression does not allow spaces. // isValidString("My Name", "([a-zA-Z]+)([a-zA-Z0-9_])*"); // Will fail. // Regular expression does allow spaces. // isValidString("My Name", "([a-zA-Z]+)([a-zA-Z0-9_ ])*"); // Will succeed. // Regular expression must be a 10 digit phone number. // isValidString("204.555.9663", "^[0-9][0-9][0-9](\\\.)[0-9][0-9][0-9](\\\.)[0-9][0-9][0-9][0-9]$"); // Will succeed. isValidString("(204)555-9663", "^[0-9][0-9][0-9](\\\.)[0-9][0-9][0-9](\\\.)[0-9][0-9][0-9][0-9]$"); // Will fail. isValidString("204-555-9663", "^[0-9][0-9][0-9](\\\.)[0-9][0-9][0-9](\\\.)[0-9][0-9][0-9][0-9]$"); // Will fail.