Regex pattern not being detected with Regex_Search function

I have a page with a single input where the user inserts a number with the following pattern: "DD-DDDD" (2 numeric digits followed by a "-" symbol and 4 numeric digits). I'm using the Regex_Search function with the following pattern: "^\d{2}-\d{4}$". 

I tested the pattern on this site and it worked. However, when i test it on my app, it always recognizes as false even though i tested with values that actually worked on that site. What am i doing wrong?

Solution

Hi b_pal,

try with a capturing group, by adding () into your regex, like this:

(^\d{2}-\d{4}$)

Then for the next parameters, set them like this and in this order, True, False, True (IgnoreCase, Multiline, Singleline).

Cheers,
Miguel


Solution

I know this is an old post but I came across it and thought I'd share how I resolved a similar issue.

I'm using the following regular expression to validate UK mobile telephone numbers: /^(((\+44)|(0))(\d{10}))$/

I built it using a very good tool to help me debug the regex: https://regex101.com/

When I transferred my regex to the Regex_Search widget, it did not work. I saw Miguel's answer and so I just removed the leading and trailing "/" and it works now. For clarity, the regex value I used was ^(((\+44)|(0))(\d{10}))$

I assume this is no longer an issue for you b_pal, but I hope this helps anyone else searching through the forum posts.

Thanks,
Rob