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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -