Hacker News new | past | comments | ask | show | jobs | submit login

My guess is they're searching for the first non-whitespace character, reverse-searching for the last non-whitespace character, and then using String.Substring to return only what's in the middle.

As to why they're not using String.Trim (https://msdn.microsoft.com/en-us/library/t97s7bs3(v=vs.110)....), maybe it's because String.Trim doesn't seem to know about the 200c whitespace character.




From what I understood, trim would work perfectly. It's 200 spaces not a single 200 width character.


You're misreading the regex. \u200c is a single whitespace character. http://www.fileformat.info/info/unicode/char/200c/index.htm


But that's a weird character to put in a comment line! I don't get how this would happen accidentally.


You really can't think this way when accepting input from users.


What difference does it make if it got in there accidentally or on purpose?

Stackoverflow is a programmers site, you must expect that a programmmer might go, "Hmm, they're trimming whitespace, wonder what happens if I put 20,000 unicode whitespace characters in there instead of normal whitespace"?


Runaway automatic search-and-replace? There's no way to distinguish intent.


Runaway search and replace won't put a single 200 width whitespace character AFAICT


That's the meaning of "runaway" - Notepad++ had a search&replace that went into a somewhat random, long and uninterruptible loop if you were replacing using some types of regex and searhing forward in the file - you had to search backwards.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: