What is a cross platform regex for removal of line breaks?

后端 未结 5 1907
囚心锁ツ
囚心锁ツ 2020-12-08 04:36

I am sure this has been asked before, but I cannot find it.

Basically, assuming you are parsing a text file of unknown origin and want to replace line breaks with so

5条回答
  •  旧巷少年郎
    2020-12-08 05:05

    Fletcher - this did get asked once before.

    Here you go: Regular Expression to match cross platform newline characters

    • Spoiler Alert!

    The regex I use when I want to be precise is "\r\n?|\n".

提交回复
热议问题