Regarding the RegEX -


i want write regular expression should allow 1 value after decimal point. 1 have written is:

(n\/a)(n\/a)|\d+.?\d{0,1} 

it accepting values per requirement problem is accepting 1. - i.e., if not giving value after decimal accepting.

in addition @wickramaranga's answer extracts first digit after decimal point if wish match on numbers can use lookarounds:

(?<!\.)\b\d+(?:\.(\d))?\b(?!\.) 

this extract first digit (not including point) ensure number has 1 digit.

note includes number no decimals.

in order require there 1 , 1 digit:

(?<!\.)\b\d+\.(\d)\b(?!\.) 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -