第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

匹配括號(hào)外的字符串

匹配括號(hào)外的字符串

呼喚遠(yuǎn)方 2022-10-12 10:21:56
我有一個(gè)帶有單詞的字符串,to如何to僅在括號(hào)外匹配該單詞(a turn; a task (a turn of work); to turn; Tongan cause Tongan turn) to到目前為止,我已經(jīng)嘗試過(guò)這個(gè)正則表達(dá)式,不幸的是它沒(méi)有用:?<!\()\bto\b(?![\w\s]*[\)])
查看完整描述

1 回答

?
海綿寶寶撒

TA貢獻(xiàn)1809條經(jīng)驗(yàn) 獲得超8個(gè)贊

括號(hào)外表示平衡文本。

解決方案是將平衡文本內(nèi)聯(lián)與要在平衡文本旁邊查找的文本匹配。你這樣做:


全局查找:


(?s)(?:(?=\()(?:(?=.*?\((?!.*?\1)(.*\)(?!.*\2).*))(?=.*?\)(?!.*?\2)(.*)).)+?.*?(?=\1)[^(]*(?=\2$)|(?!to|[()]).)*?((?:(?!(?=\()(?:(?=.*?\((?!.*?\4)(.*\)(?!.*\5).*))(?=.*?\)(?!.*?\5)(.*)).)+?.*?(?=\4)[^(]*(?=\5$))(?!to|[()]).)*)(to)

要查看您找到的內(nèi)容,請(qǐng)?zhí)鎿Q為


<$3$6>

之前的示例文本:


to (F(i(r(s)t))) ((S)(e)((c)(o))(n)d) (((((((Third))))))) hello to 

where is a to and this is also to

(F(i(r(s)t))) ((S)(e)((c)(o))(n)d) (((((((Third)))))))

((123),(456),(789))

(a turn; a task (a turn of work); to turn; Tongan cause Tongan turn) (dsaf)

This is a you to as well as this to  here ( asdf )

然后更換后:


<to>< hello to>< 

where is a to>< and this is also to><

This is a you to>< as well as this to>  here ( asdf )

演示


正則表達(dá)式字符串:


"(?s)(?:(?=\\()(?:(?=.*?\\((?!.*?\\1)(.*\\)(?!.*\\2).*))(?=.*?\\)(?!.*?\\2)(.*)).)+?.*?(?=\\1)[^(]*(?=\\2$)|(?!to|[()]).)*?((?:(?!(?=\\()(?:(?=.*?\\((?!.*?\\4)(.*\\)(?!.*\\5).*))(?=.*?\\)(?!.*?\\5)(.*)).)+?.*?(?=\\4)[^(]*(?=\\5$))(?!to|[()]).)*)(to)"

正則表達(dá)式可讀代碼:


 (?s)

 (?:

      (?= \( )

      (?:

           (?=

                .*? \(

                (?! .*? \1 )

                (                             # (1 start)

                     .* \)

                     (?! .* \2 )

                     .* 

                )                             # (1 end)

           )

           (?=

                .*? \)

                (?! .*? \2 )

                ( .* )                        # (2)

           )

           . 

      )+?

      .*? 

      (?= \1 )

      [^(]* 

      (?= \2 $ )

   |  (?! to | [()] )

      . 

 )*?

 (                             # (3 start)

      (?:

           (?!

                (?= \( )

                (?:

                     (?=

                          .*? \(

                          (?! .*? \4 )

                          (                             # (4 start)

                               .* \)

                               (?! .* \5 )

                               .* 

                          )                             # (4 end)

                     )

                     (?=

                          .*? \)

                          (?! .*? \5 )

                          ( .* )                        # (5)

                     )

                     . 

                )+?

                .*? 

                (?= \4 )

                [^(]* 

                (?= \5 $ )

           )

           (?! to | [()] )

           . 

      )*

 )                             # (3 end)

 ( to )                        # (6)

祝你好運(yùn) !


查看完整回答
反對(duì) 回復(fù) 2022-10-12
  • 1 回答
  • 0 關(guān)注
  • 142 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)