【发布时间】:2016-06-24 05:37:41
【问题描述】:
如何删除\r\n 位于所有不同位置的短语或句子?
例如,我要删除这样一个句子:
If you are having trouble viewing this message or would like to share
it on a social network, you can view the message online.
但是这句话有很多不同的变体,比如:
If
you are having trouble viewing this message or would like to share
it on a social network, you can view the message online.
或
If you are having trouble
viewing this message or would like to share
it on a social network, you can view the message online.
我试图指定正则表达式中的每一个变体,但是当句子或短语很短时,这是可能的。
例如,如果我想删除Please contact me immediately
我可以指定Please\r\ncontact me immediatelyPlease contact\r\nme immediatelyPlease contact me\r\n immediatelyPlease contact me\r\nimmediately去掉这句话。但是如果我想删除一个较长的句子,就像我的第一个例子一样,我不能写出所有可能的变化。
总而言之,我如何删除具有相同单词但在所有不同位置都有 \r\n 的短语和句子?
【问题讨论】:
-
根据这些句子出现的空间不应该有
\r或\n吗?