简体   繁体   English

RegEx不匹配没有回车的回车

[英]RegEx Not Matching Carriage Return without Linefeed

Why is this simple regex not matching a carriage return? 为什么这个简单的正则表达式不匹配回车符? For reference, my data is the result of a SQL query and I have replaced linefeed \\n with a single space. 作为参考,我的数据是SQL查询的结果,并且我已将换行\\ n替换为一个空格。

\r

SRUS55 KSLC 082010\r\r HMTSLC\r\r 

There is no \\r in your demo. 您的演示中没有\\r

This is a newline character, either you were looking for \\\\r or [\\n\\r]+ if your string happens to include newlines. 这是换行符,如果您的字符串碰巧包含换行符,则您正在寻找\\\\r[\\n\\r]+

For a more in-depth answer, see this explanation . 有关更深入的答案, 请参见以下说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM