<![CDATA[ TV Text RegEx - not working - My Forums]]> https://forums.modx.com/thread/?thread=98116 <![CDATA[TV Text RegEx - not working]]> https://forums.modx.com/thread/98116/tv-text-regex---not-working?page=2#dis-post-530531 http://www.regexr.com/ to test them after I couldn't get my own ones to work and nothing. It always gives me the error, even with a string that validates on regexr.com and other regular expresion testers. Is this functionality broken? Do I have to write it diferently?

I have tried writing the expression with and without the leading and trailing /, with and without a g, for example:

\b\d{3}[-.]?\d{3}[-.]?\d{4}\b
/\b\d{3}[-.]?\d{3}[-.]?\d{4}\b/
/\b\d{3}[-.]?\d{3}[-.]?\d{4}\b/g]]>
guategeek Aug 25, 2015, 05:19 PM https://forums.modx.com/thread/98116/tv-text-regex---not-working?page=2#dis-post-530531
<![CDATA[Re: TV Text RegEx - not working]]> https://forums.modx.com/thread/98116/tv-text-regex---not-working?page=2#dis-post-559398 https://github.com/modxcms/revolution/issues/13899]]> BobRay Jul 08, 2018, 06:16 AM https://forums.modx.com/thread/98116/tv-text-regex---not-working?page=2#dis-post-559398 <![CDATA[Re: TV Text RegEx - not working]]> https://forums.modx.com/thread/98116/tv-text-regex---not-working#dis-post-559395
new RegExp('{$params.regex}')


So a regex literal, example:
/^[\w]{11}$/
would need to be entered like this instead:
^[\\w]{11}$
]]>
sepiariver Jul 07, 2018, 10:22 PM https://forums.modx.com/thread/98116/tv-text-regex---not-working#dis-post-559395
<![CDATA[Re: TV Text RegEx - not working]]> https://forums.modx.com/thread/98116/tv-text-regex---not-working#dis-post-549994 Jako Apr 10, 2017, 06:38 AM https://forums.modx.com/thread/98116/tv-text-regex---not-working#dis-post-549994 <![CDATA[Re: TV Text RegEx - not working]]> https://forums.modx.com/thread/98116/tv-text-regex---not-working#dis-post-549993 jcdm Apr 10, 2017, 06:20 AM https://forums.modx.com/thread/98116/tv-text-regex---not-working#dis-post-549993 <![CDATA[Re: TV Text RegEx - not working]]> https://forums.modx.com/thread/98116/tv-text-regex---not-working#dis-post-542598
On the page https://regex101.com/#javascript you could generate and test your regular expressions. After you have generated a valid expression, click on 'code generator' and the tool will escape the expression for you. Copy the properly escaped code of the tool without the delimiters to the regular expression field in MODX.

In your case it should be
\\b\\d{3}[\\-.]?\\d{3}[\\-.]?\\d{4}\\b
]]>
Jako Jun 20, 2016, 01:47 AM https://forums.modx.com/thread/98116/tv-text-regex---not-working#dis-post-542598
<![CDATA[Re: TV Text RegEx - not working]]> https://forums.modx.com/thread/98116/tv-text-regex---not-working#dis-post-537691
[0-9]{3}\-[0-9]{3}\-[0-9]{4}

It works well.]]>
cageybee Jan 31, 2016, 05:30 PM https://forums.modx.com/thread/98116/tv-text-regex---not-working#dis-post-537691
<![CDATA[Re: TV Text RegEx - not working]]> https://forums.modx.com/thread/98116/tv-text-regex---not-working#dis-post-531051 BobRay Sep 04, 2015, 03:51 PM https://forums.modx.com/thread/98116/tv-text-regex---not-working#dis-post-531051 <![CDATA[Re: TV Text RegEx - not working]]> https://forums.modx.com/thread/98116/tv-text-regex---not-working#dis-post-531041
I also tried my previous example but with the correct escaping character [\-.] for the character class and that didn't work ether.

/\b\d{3}[\-.]?\d{3}[\-.]?\d{4}\b/


This obviously isn't anything I have knowledge about but I'm wondering if something is broken with MODX TV RegEx validation.]]>
guategeek Sep 04, 2015, 01:02 PM https://forums.modx.com/thread/98116/tv-text-regex---not-working#dis-post-531041
<![CDATA[Re: TV Text RegEx - not working]]> https://forums.modx.com/thread/98116/tv-text-regex---not-working#dis-post-530809
\b\d{3}[.-]\d{3}[.-]\d{4}\b


The regexp code doesn't add a delimiter, so you'd have to add a delimiter to each end like this:

/\b\d{3}[.-]\d{3}[.-]\d{4}\b/


or

@\b\d{3}[.-]\d{3}[.-]\d{4}\b@


or
%\b\d{3}[.-]\d{3}[.-]\d{4}\b%


The code uses preg_match(), which doesn't take the /g modifier, so that will always cause an error. Withoug it, you'll only get the first match unless you write your own custom validator that uses preg_match_all().
]]>
BobRay Aug 31, 2015, 06:13 PM https://forums.modx.com/thread/98116/tv-text-regex---not-working#dis-post-530809