正则表达式:找到几个换行符
您好,我有这个 html 标记
<body>
<table border="0" width="50%" align="center">
<tr>
<td>
<center>
,我正在尝试为换行符找到一个“通配符”以到达
标记 - 这将如何工作?谢谢
hi i'm having this html markup
<body>
<table border="0" width="50%" align="center">
<tr>
<td>
<center>
and i'm trying to find a "wildcard" for the linebreaks to reach the <center>
tag - how would this work?
thx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于某些平台使用
\r\n
作为换行符,而有些平台仅使用\n
这将搜索连续的空格字符串(也应该考虑 \r),后跟
\n
,并确保匹配其中的 2 个。Firebug 控制台测试:
Since some platforms use
\r\n
as their line-break, and some use only\n
this will search forsuccessive strings of whitespace (which \r should also be considered) followed by
\n
, and ensure to match 2 of them.Firebug console test:
查找重复换行符的正常正则表达式是“[\r\n]+”,这意味着至少有 1 个换行符。这将匹配任意数量的紧随其后的换行符。
The normal RegEx to find a repeating linebreak is "[\r\n]+" which means at least 1 linebreak. This will match any number of linebreaks following directly after each other.