Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我很难将字符串文字与换行符(\n)和回车符(\r)匹配。例如:
"132 Holt Court, Cashtown, Rhode Island, 7680 \n\r"
我尝试的是
\"([^\\\"]|\\.)*\"
但是这个正则表达式只能匹配上面没有\r. 谁能帮我解决这个问题?
\r
谢谢你。
您总是可以在检查之前先删除它们。
例如:
String s = "132 Holt Court, Cashtown, Rhode Island, 7680 \n\r" s=s.replace("\\n\\r","\\n");