[英]Regex to match second line
I am trying to use an expression in WebHarvy (.NET) to match the 2nd line in a paragraph, with a double line break between them我正在尝试使用 WebHarvy (.NET) 中的表达式来匹配段落中的第二行,它们之间有一个双换行符
Example例子
This is the first line
这是第一行
This is the second line
这是第二行
I have tried using \n(.*)\n\n
but it returns the empty line break instead of the second line.我试过使用
\n(.*)\n\n
但它返回空换行符而不是第二行。
Please check https://regex101.com/r/9GjHTM/1请查看https://regex101.com/r/9GjHTM/1
Kindly advise好心提醒
Thanks谢谢
In WebHarvey regex , you can capture what you need: 在WebHarvey regex中 ,您可以捕获所需的内容:
WebHarvy will extract only those portion(s) of the main text which matches the
group(s)
specified in the RegEx string.WebHarvy将仅提取与RegEx字符串中指定的
group(s)
匹配的主要文本部分。
So, use 所以用
(?:\r\n?|\n){2}(.+)
The expression matches: 表达式匹配:
(?:\\r\\n?|\\n){2}
- exactly two occurrences ( {2}
) of (?:\\r\\n?|\\n){2}
-恰好出现了两次( {2}
)
\\r\\n?
- a CR (carriage return) followed by 1 or 0 (=optional) LF (newlines) |
- or \\n
- an LF (a newline) \\n
-LF(换行符) (.+)
- Capturing group 1 (the substring matched with this subpattern will be output by WebHarvey) (.+)
-捕获组1(与此子模式匹配的子字符串将由WebHarvey输出) You can try this for match second line in Regular Expression (REGEX)您可以在正则表达式 (REGEX) 中尝试匹配第二行
Regex: \n.*
正则表达式:
\n.*
Example:例子:
var regex = /\n.*/; var str = `1st line 2nd line 3rd line`; document.write(str.match(regex));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.