[英]Use regex to capture next line of text after newline
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) ^.*$\\n
将捕获整行及其换行符(必须存在换行符才能捕获)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.