Check if strong contains 6 numbers

Hey guys

Suppose I have some strings;

  1. SHARMIN - 123456
  2. JAKE - 12345
  3. SAMUEL - 123467
  4. HARJ - 123456

What expression can I use to check if the string contains only 6 digits/numbers.

So for above examples;
Correct/True = 1 & 4
Incorrect/False = 2 & 3

Thanks!

Hi,

Can you try the following expression?

System.Text.RegularExpressions.Regex.IsMatch(text,"(^|\D)\d{6}($|\D)")

Regards,

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.