Using a RegEx to trigger an action | XM Community
Solved

Using a RegEx to trigger an action


Hello all!

I am trying to create an action which would be triggered by the presence of any of a large quantity of terms in an open ended response.

Would the correct condition be the following:
Question > Question Name > Question Text > Matches RegEx > /(term1)|(term2)|(term3)|.../(termn)/gi/

Does the RegEx need to be preceded by anything other than "/"? do the end flags (g/i) need to be followed by "/"?

Cheers!

Joachim
icon

Best answer by mattyb513 10 July 2018, 16:05

View original

7 replies

Userlevel 6
Badge +6
Yeah, your approach is correct. You would literally just drop it in like the following:
```
/(term1)|(term2)|(term3)|(termn)/gi
```
Obviously swapping out the terms for real terms. If any of them match in this case it will pass the validation. This validation would be on the question that contains the text entry box typically.

Example: https://qualtricssfi.az1.qualtrics.com/jfe/preview/SV_dgr675yqpa0YWvH?Q_SurveyVersionID=current&Q_CHL=preview
Userlevel 7
Badge +38
If you happen to have trouble with the RegEx you can also use display logic for this. One line for each term with the condition.

Question > Question Name > Question Text > Contains > (term 1)
OR Question > Question Name > Question Text > Contains > (term 2)
OR Question > Question Name > Question Text > Contains > (term 3)...

You would lose the benefit of the case insensitive code from the RegEx though.
Thanks @bstrahin ; my main issue is that I have 50~ terms that I want to use to trigger this action.. and that I need to reproduce this action across multiple surveys. Definitely a great albeit labor intensive plan b!
> @mattyb513 said:
> Yeah, your approach is correct. You would literally just drop it in like the following:
> ```
> /(term1)|(term2)|(term3)|(termn)/gi
> ```
> Obviously swapping out the terms for real terms. If any of them match in this case it will pass the validation. This validation would be on the question that contains the text entry box typically.
>
> Example: https://qualtricssfi.az1.qualtrics.com/jfe/preview/SV_dgr675yqpa0YWvH?Q_SurveyVersionID=current&Q_CHL=preview

Thanks @mattyb513 ; your example shows the regex validation used for survey logic. Would the same regex be valid when using "Matches RegEx" to trigger actions (ticketing/email?).

Cheers!
Userlevel 6
Badge +6
Yeah, I'd imagine that it's using the same engine for all its regex evaluation. Are you seeing differently?
@mattyb513 Between my question and now I've managed to successfully test, can confirm that it works as you said it would!
Userlevel 6
Badge +7
> @mattyb513 said:
> ^ Whoops - wrong thread but I can't delete this for some reason. Sorry!

No worries! Deleted now!

Leave a Reply