regex - regular expression for "measure units" -


i need regex support custom measure units. example:

1g valid gb valid 1  invalid m2 valid mt valid 22 invalid 

can support numbers words. not numbers. can me?

^(?!\d+$)[a-za-z0-9]+$ 

try this.see demo.

http://regex101.com/r/yr3mm3/5

this not allow string containing numbers.

you can use

^(?!\d+$)[a-za-z0-9]{1,2}$ 

if want allow upto 2 digits


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -