Introduction to Regular Expressions (RegEx)


Regular expressions are patterns of characters that can be used in order to check if some text is matching your requested pattern.

Few examples to the usage of regular expressions is validation a phone number pattern, an identification code, zip codes etc. that are entered by the surveyor/respondent during an interview as text in open ended questions.


How To use regular expressions?

SurveyToGo has a built-in function called dblIsRegEx.

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 an example RegEx for validating email addresses:


Please note: this is only an example, we have already a predefined function that validates the email address called !IsEMail(Answer(CurrQues)).

We would like to check if the answer of anOpen Ended question which asks for the respondents email, is a valid email address.

We will use the following Validation Rule condition:

And as you can see, if we enter a not valid email address the following message will appear and the interview will not be allowed to proceed.

When writing your Regular Expression, please note that as we pass it as a string parameter to the function, when needing to write a back-slash '\' as part of he rule, it should be written twice, like this: '\\'.

So for example to have a rule where you allow only non digit characters to be entered, in Rubular you would write it as ^\D$, but in the validation rule you would write it as:

!dblIsRegEx("^\\D$", Answer(CurrQues));

For quick reference of the syntax and testing your regular expressions we recommend using the following site:

You can find a few examples in this sample survey:

RegEx Quick Reference

We placed here a screenshot with the most common regular expression operators for a quick reference (the below is taken from the Rubular site):

That’s it!

Visit us at:

Was this article helpful?
1 out of 1 found this helpful
Have more questions? Submit a request



Please sign in to leave a comment.