I want to use regex to validate my numbers before using them, but it didn't work.
I want the first number to start with 0, followed by 2 or 5, then 4, and the remaining numbers continue to 10 digits.
<?php $str = "0241310102"; $pattern = "([0]{1}[2,5]{1}[4]{1}[0-9]{7})"; if(preg_match($pattern, $str)){ echo "YES"; }else{ echo "NO"; } ?>
^
,$
).[0]
→0
0{1}
→0
[2,5]
will include commas in character classes →[25]