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

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -