My compiler is evaluating "15 000,00" == "15 000,00" to false in JScript. Can someone point me to the correct regex expression to remove any hidden characters affecting the comparison?
2 Answers
Try Trimming(removing white spaces at ends) the strings since even if your string contains white spaces at ends this will return false.
"15 000,00" == "15 000,00 " => This will return you false.
But trimming as shown below will return you true.
"15 000,00" == "15 000,00 ".trim()
3 Comments
sheebs
Yes, I've tried this but the hidden character seems to be the space in between 5 and 0 which is unaffected by trim.
Naren K
Sorru S.S. but i am not able to reproduce your scenario at my end.
Naren K
Hi @S.S. Please try following expression for both the parameters and let me know if it works ("15 000,00 ").replace(/[^a-z0-9\s\w]/gi, '').replace(/[_\s]/g, '') Here replace(/[^a-z0-9\s\w]/gi, '') will remove all the special characters here like , (It will replace all the special characters with space). Then replace(/[_\s]/g, '') this will remove all the empty spaces in the string.
replace('[^\w]', '')... it is not the right syntax but you can find out from it.