Do embedded fields used in regular expressions need escape characters? | XM Community
Question

Do embedded fields used in regular expressions need escape characters?

  • 21 December 2020
  • 1 reply
  • 43 views

I want to use a regular expression that matches an embedded field in custom validation.
The embedded field may contain characters that need to be escaped in the regex, such as a dot.
Let's say, for example, that the value of the embedded field website1 is mysite.com.
I want the regex to take it literally and not use the dot as a wildcard.
Would it work if I add ${e://Field/website1} into the expression?
Or do I need to have the embedded field value with the escape character?
Thanks for your help.


1 reply

Userlevel 7
Badge +27

You would never pipe a string into a regex. You escape the characters in the regex, not in the piped string. Your condition might look something like like:
If Embedded Data website1 matches regex ^.*\\..*$

Leave a Reply