regula - regex For Float Numbers with Limits -


i need regex expression floating , whole numbers have limit accept 1 or 2 digit before point , 1 or 2 digits after point. whole number limit should 2 digit. should valid:

 - 1.1  - 11.1  - 1.11  - 11.11  - 2  - 22  should invalid:   - 111.111  - 222 here regex: /^\d{1,2}(\.\d){1,2}?$/   not working kindly me in 

use following pattern:

^\d{1,2}(?:\.\d{1,2})?$ 

see the regex demo.

enter image description here

details:

  • ^ - start of string
  • \d{1,2} - 1 or 2 digits
  • (?:\.\d{1,2})? - optional sequence of:
    • \. - dot
    • \d{1,2} - 1 or 2 digits
  • $ - end of string.

Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -