什么是用于删除换行符的跨平台正则表达式? [英] What is a cross platform regex for removal of line breaks?

查看:104
本文介绍了什么是用于删除换行符的跨平台正则表达式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确定以前已经问过这个问题,但是我找不到它.

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 some other delimiter, is this the best regex, or is there another?

(\r\n)|(\n)|(\r)

推荐答案

弗莱彻(Fletcher)-确实曾经被问过一次.

Fletcher - this did get asked once before.

您在这里:用于与跨平台换行符匹配的正则表达式

  • 扰流板警报!

我想成为时使用的正则表达式 精确的是"\ r \ n?| \ n".

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

这篇关于什么是用于删除换行符的跨平台正则表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆