Remix.run Logo
inigyou a day ago

Sure, start with \r\n, split on \n, now you have a stray \r at the end of every input.

Retr0id a day ago | parent | next [-]

But 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?

inigyou 21 hours ago | parent [-]

Someone else (possibly you) already split on \n.

Retr0id 20 hours ago | parent [-]

Fair point. I think if something is getting mangled like that I'd rather fail loudly, but it depends on the use case I suppose.

HackerThemAll 21 hours ago | parent | prev [-]

\r\n?|\n

handles all EOL sequences without backtracking. Or write a non-regex equivalent of that.

inigyou 20 hours ago | parent [-]

I'm sure every time you split something on newlines you remember to use a regex.

HackerThemAll 18 hours ago | parent [-]

I tend not to, because it's an overkill, but this regex nicely sums what needs to be done.