I have two variables. Variable 1 is in the format
" 35"
while variable 2 is just
35
How would I compare these two?
You can just use:
var1.replaceAll("\\W+", "").equals( var2.replaceAll("\\W+", "") )
Here replaceAll("\\\\W+", "")
will remove all non-word characters from both variables before comparing.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.