This regular expression matches a string that contains one or two digits ('\d{1,2}') followed by an optional decimal point and one or two more digits ('(.\d{1,2})?').

Here are some examples of strings that would match this regular expression:

  • '1'
  • '12'
  • '1.5'
  • '22.75'

And here are some examples of strings that would not match:

  • '0.123' (more than two digits after the decimal point)
  • '3.' (decimal point without any digits after it)
  • '1.23456' (more than two digits after the decimal point)
Regular Expression for Matching Numbers with Optional Decimal Points

原文地址: https://www.cveoy.top/t/topic/lGqc 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录