0

I have created a regex that catches only numbers that are 14 digits long and start with 25, which works correctly.

if (preg_match('/(?=\d{14}$)(25)\d+/', $valid_id)){
    $return_value = 1;
}

If I type something before the number it works fine. However, as soon as I write something (space, letter, digit) after the number the regex stops working and no longer catches it.

For example:

$valid_id = "the id is 25000000000000";

It catches the number, but if I write

$valid_id = "the id is 25000000000000 and it is valid";

Then it doesnt.

I presume I am missing something at the end of the regex, but cant figure it out.

lStoilov
  • 1,256
  • 3
  • 14
  • 30

0 Answers0