regex - a decimal without an integer part -


i use following expression match decimal number

\d+[.,]?\d+ 

i trying make digits before decimal separator optional, thought following should do

\d+?[.,]?\d+ 

but did not, can 1 please explain why?

as trying make match of following examples

    44     44.44     44,44     .44     ,44 

i trying make digits before decimal separator optiona

just use * quantifier first \d , set ? quantifier character class:

\d*[.,]?\d+ 

see regex demo

the reason expression not work \d+? requires @ least 1 digit match.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -