regex - Check if String has only Integers separated by comma in PHP -
I'm really empty on the Regex side and this is the reason why PHP can create a regex, which checks Is this special sequence of string characters?
$ str = '2323,321,329,34938,23123,54545,123123,312312'; To check whether the only integer in the string (decimal, no alphabet or nothing else) is separated by commas (,).
'/ ^ \ d + (? ,, \ D +) * $ /' code: $ re = '/ ^ \ d + (?:, \ D +) * $ / '; $ Str = '2323,321,329,34 938,23123,54545,123123,312312'; If (preg_match ($ re, $ str)) echo "correct format"; Else echo "wrong format";
Comments
Post a Comment