2 ms·
Sure, start with \r\n, split on \n, now you have a stray \r at the end of every input.
by inigyou 3mo ago
Sure, start with \r\n, split on \n, now you have a stray \r at the end of every input.
- Retr0id 3mo agoBut the preceding clause says it handles \r\n. If you're already handling \r\n, what remaining sources of \r are there, that you'd actually want to silently ignore?
- HackerThemAll 3mo ago\r\n?|\n handles all EOL sequences without backtracking. Or write a non-regex equivalent of that.
- inigyou 3mo agoI'm sure every time you split something on newlines you remember to use a regex.
- HackerThemAll 3mo agoI tend not to, because it's an overkill, but this regex nicely sums what needs to be done.