1

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?

1
  • replace('[^\w]', '') ... it is not the right syntax but you can find out from it. Commented Dec 8, 2013 at 5:22

2 Answers 2

1

FYI: Replace the space ' '(Unicode value:160) with space ' '(Unicode value:32) did the trick.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Yes, I've tried this but the hidden character seems to be the space in between 5 and 0 which is unaffected by trim.
Sorru S.S. but i am not able to reproduce your scenario at my end.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.