繁体   English   中英

正则表达式匹配之间的所有内容

[英]Regex match everything not in between

所以我有一个像文本一样的文本

This is a text
+++ Everything in here shouldn't be matched +++
This should be matched
+++ This should neither +++

我希望匹配“+++”和“+++”之间的所有内容(不包括“+++”)

我认为它可以用“而不是+++”

.(?=(?:[^"]*"[^"]*")*[^"]*\Z)

但我无法找到,如何用“+++”作为指标来做到这一点。

你可以使用这个正则表达式:

\+\+\+.*?\+\+\+

并用空字符串替换它。 剩下的就是你要找的文字:

This is a text

This should be matched

是一个例子。

我会使用以下内容来匹配不在+++之间的每一行

/^\w.*$/gm

示例: https//regex101.com/r/zAoON1/2

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM