Sample text:
First line of text.
Second line of text with a newline here
that continues here. I need to capture this last line.
This is my first regex. Here's where my brain stopped working:
\n([^>]+)>
It captures all the way back to the first newline at the end of the "First line of text."
I'm not coding, I'm using a module that accepts expressions, so, using regex only, without methods, How do I work back from the ">" to either
This happens because [^>]
matches newline characters. If you remove newlines from the character class it should work:
([^>\n]+)>
^
captures beginning of a line
$
captures the end of a line
^.*$\\n
will capture an entire line and its line break (line break must exist for this to capture)
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.