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
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.
Please check https://regex101.com/r/9GjHTM/1
Kindly advise
Thanks
In WebHarvey regex , you can capture what you need:
WebHarvy will extract only those portion(s) of the main text which matches the
group(s)
specified in the RegEx string.
So, use
(?:\r\n?|\n){2}(.+)
The expression matches:
(?:\\r\\n?|\\n){2}
- exactly two occurrences ( {2}
) of
\\r\\n?
- a CR (carriage return) followed by 1 or 0 (=optional) LF (newlines) |
- or \\n
- an LF (a newline) (.+)
- Capturing group 1 (the substring matched with this subpattern will be output by WebHarvey) You can try this for match second line in Regular Expression (REGEX)
Regex: \n.*
Example:
var regex = /\n.*/; var str = `1st line 2nd line 3rd line`; document.write(str.match(regex));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.