我试图创建一个可以检测降价报价块的正则表达式 到目前为止,这是我的正则表达式:
(?:^|\n)[ \t]*(>[ \t]*\S(?:(?!\n(\s*\n)+[^>])[\s\S])*)
(?:^|\n) beginning of string, or a line break
[ \t]* optional spaces
>[ \t]*\S `>` followed by optional spaces and at least one character
( ... [\s\S])* capture any following character\white-space multiple times
(?!\n(\s*\n)+[^>]) stop capture if next following characters are
at least 2 line breaks mixed with other white-spaces
followed by anything but `>`
一切正常,除了否定前瞻:如果遇到超过2个换行符,捕获就会停止。
当需要时,Regex101向我展示了4个匹配。任何指针?
答案 0 :(得分:1)