括号中的多行正则表达式匹配模式忽略转义括号
multiline regex match pattern in brackets ignoring escaped brackets
我终于找到了方法,请参阅 https://regex101.com/r/Zls9Kq/5/
(?!\)[{](.|\n)*?(?<!\)[}]
正在尝试匹配
sometext {
blah \{
\}
\{
\}
}
但是这个表达式不能在 flex 中使用。
有人知道是否可以将其转换为适用于 flex 的方式吗?
我将假设一个有限的正则表达式引擎并给你这个来试用
([^\]|^)[{]([^\}]|\(.|\n))*[}]
https://regex101.com/r/WBFbWw/1
**
( [^\] | ^ ) # (1), Before the opening {, match not an escape or the beginning of the string
[{] # Opening brace
( # (2 start)
[^\}] # Not an escape nor a closing brace
| \ # Or, an escape anything
( . | \n ) # (3)
)* # (2 end), 0 to many times
[}] # Closing brace
我终于找到了方法,请参阅 https://regex101.com/r/Zls9Kq/5/
(?!\)[{](.|\n)*?(?<!\)[}]
正在尝试匹配
sometext {
blah \{
\}
\{
\}
}
但是这个表达式不能在 flex 中使用。
有人知道是否可以将其转换为适用于 flex 的方式吗?
我将假设一个有限的正则表达式引擎并给你这个来试用
([^\]|^)[{]([^\}]|\(.|\n))*[}]
https://regex101.com/r/WBFbWw/1
**
( [^\] | ^ ) # (1), Before the opening {, match not an escape or the beginning of the string
[{] # Opening brace
( # (2 start)
[^\}] # Not an escape nor a closing brace
| \ # Or, an escape anything
( . | \n ) # (3)
)* # (2 end), 0 to many times
[}] # Closing brace