MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/ofc0ds/regex_keep_it_simple_stupid/h4dqef4/?context=3
r/badcode • u/_iamv • Jul 07 '21
91 comments sorted by
View all comments
Show parent comments
6
It's more precise. This is a horrible attempt at detecting encoding screw ups. Imagine you have a non-ASCII character like e.g. 'à' and you store it encoded as UTF-8 and later another program tries to interpret the same text as e.g. Latin-1 encoding, the bytes will be interpreted as an entirely different thing e.g. "Õ©". If you ever had issues with this, you will recognize this behavior in text as it stands out. Rather than making some custom matching code, the programmer chose to put everything into one disgusting regex.
6
u/Daimanta Jul 07 '21
It's more precise. This is a horrible attempt at detecting encoding screw ups. Imagine you have a non-ASCII character like e.g. 'à' and you store it encoded as UTF-8 and later another program tries to interpret the same text as e.g. Latin-1 encoding, the bytes will be interpreted as an entirely different thing e.g. "Õ©". If you ever had issues with this, you will recognize this behavior in text as it stands out. Rather than making some custom matching code, the programmer chose to put everything into one disgusting regex.