我想匹配之后的所有內容,\t(\fn但只在之前\并且不包括屬于的最后一個括號\(t(如您在附圖中所見)
為了這 :
\t(\fnJester (BIG))
\t(\fnJester (BIG))\i1
\t(\fnJester (BIG)
\t(\fnJester))))\fnArial (BOLD)\
我想匹配:
Jester (BIG)
Jester (BIG)
Jester (BIG
Jester)))) and Arial (BOLD
我幾乎有這種模式:
(?<=\\t\(.*?\\fn).*(?=\)|\\)
但由于它是貪婪的,它甚至在之后匹配一切\

uj5u.com熱心網友回復:
你可以匹配正則運算式
(?<=fn)[^\\]*(?=\)|\\fn)
演示
運算式可以分解如下。
(?<= # begin a positive lookbehind
fn # match 'fn'
) # end positive lookbehind
[^\\]* # match zero or more chars other than '\'
(?= # begin a positive lookahead
\) # match ')'
| # or
\\fn # match '\fn\
) # end positive lookahead
uj5u.com熱心網友回復:
你可以使用這個正則運算式:
(?<=\\fn).*?(?=\\fn|\)(?:\\(?!fn)|$))
更新的 RegEx 演示
(?=\\fn|\)(?:\\(?!fn)|$))是確保我們的匹配以 optional 結尾\fn或)后跟的前瞻條件\。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/468606.html
標籤:正则表达式
上一篇:Nginx正則運算式位置不匹配
下一篇:Python中位元組的正則運算式
