Question:
Having this String with decimal point, I would like to remove all non alphaNumeric expect the decimal point."the. book cost 7.55 dollars."
;However I would like to return
"the book cost 7.55 dollars"
;Answer:
You can use:RegEx Details:
(?<!\\d)
: Previous character is not a digit\\.
: Match a dot(?!\\d)
: Next character is not a digit|
: OR[^a-zA-Z\\d. ]+
: Match 1+ of non-alphanumeric characters that are not space or dot.replaceAll("\\h{2,}", " ")
: is for replacing 2+ whitespaces with a single space
If you have better answer, please add a comment about this, thank you!