Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

utterly weird behavior in basic string comparison

this doesn't make any sense to me. must be wrong or painfully obvious.

after slicing and dicing, i got 2 vars with the following values in vb.net:

strTag = "&lt;#<span class=SpellE>vermittler_person_Name</span>&gt;"
tmp    = "&lt;#<span class=SpellE>vermittler_person_Name</span>&gt;"

comparing the vars gives a false:

strTag = tmp ' ==> false

comparing the values directly right there gives a true:

"&lt;#<span class=SpellE>vermittler_person_Name</span>&gt;" = "&lt;#<span class=SpellE>vermittler_person_Name</span>&gt;" ' ==> true

both are strings, i tried all kinds of stuff: string.compare, string.equals, also regex etc. etc. everything works perfect with all the other strings with simlilar structure, just not and only not with

"vermittler_person_Name"

in the middle... any ideas?

like image 435
handsomeGun Avatar asked Sep 14 '26 02:09

handsomeGun


2 Answers

I strongly suspect that although the two displayed strings were equal, the internal data wasn't equal. There could be any number of non-printing characters in there.

If you're able to reproduce this, I suggest you look at the Unicode value of each character of the offending strings. If I'm right, we won't be able to reproduce this via an SO post which only contains the visible characters, for obvious reasons.

like image 59
Jon Skeet Avatar answered Sep 16 '26 16:09

Jon Skeet


you can check the lengths of the two strings to see if they're the same, or convert both of them to the same case (upper or lower) to see if that's causing the difference

like image 26
Beth Avatar answered Sep 16 '26 16:09

Beth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!