Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

regex for integer and .0 number

I need regex for integer number or decimal number with .0

approved:
35
35.0

not approved:
any other decimal (35.7, 35.989)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

One way:

^\d+(?:\.0)?$
  • ^ – start of line anchor
  • \d+ – one or more digits
  • (?: – start of non-capturing group
    • \.0 – A literal . followed by 0
  • ) – end of non-capturing group
  • ? – 0 or 1 match of the previous match (the non-capturing group matching on \.0)
  • $ – end of line anchor

Demo

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading