Wednesday 26 February 2014

[MySQL] - Regular Expressions - How to check a decimal number

To check if the field value is a decimal number, you can use the following expresion

REGEXP '^[[:digit:]]+\\.{0,1}[[:digit:]]*$'

Example: 
select '3.222' REGEXP '^[[:digit:]]+\\.{0,1}[[:digit:]]*$' as prueba;

1 comment:

  1. hi.. new to regexp.. what about if there is an optional sign (+ or -) at the start of the text value...

    ReplyDelete