How To: Introduction to Regular Expressions (RegEx)
Regular expressions are patterns of characters which are used in order to check if some text is matched to your requests.
A common known usage of regular expression is when demanding a valid email address in a free text question – regular expressions allows you to validate if the input is a valid email address.
RegEx Quick Reference
How To Do It?
SurveyToGo has a built-in function called IsRegEx, this function
gets two parameters:
1st parameter is the RegEx expression.
2nd parameter is the text to check.
This function returns ‘true’ if the text is valid according to the RegEx expression, or ‘false’ if the text is not valid according to the RegEx expression.
Let’s look on the email validation example.
Here is a RegEx I took from the internet for validating email addresses:
Just for my convenience, I have placed it inside a global variable, so I don’t need to write the whole expression when I wish to use it.
*Here is a ‘How-To’ about Global Variables
You can implement this global variable wherever you want in your survey.
Now, I would like to check if the answer of my Open Ended question which asks for the respondents email, is a valid email address.
I have created the following Validation Rule:
This basically checks if the RegEx is NOT valid.
And have configured it to prompt if the email is not valid.
And as you can see, I have entered a not valid email address, and the validation RegEx rule has saved the day!
Other Usages Of RegEx?
Basically RegEx can come in hand in a vast range of ways, for example:
– Validating a certain code which has to match a certain pattern (like Bar-Codes, Policy-Codes, etc’).
– Validating a certain pattern of phone number.
– And any pattern of text you have in mind.
There is a lot of info about RegEx in the internet, as this is a whole language for validating text patterns.
For quick reference of the language syntax and testing your regular expressions on your text, I would recommend using the following site:
It has a RegEx validation tool and a quick reference for RegEx syntax.
Visit us at: http://www.dooblo.net