簡體   English   中英

在Notepad ++中使用Regex,如何只選擇某些特定行內的句點而不選擇其他行內的句點

[英]Using Regex in Notepad++, how do I select only the period inside some specific lines but not inside others

在Notepad ++中使用Regex,如何僅選擇以下行中的句點:

<div class="english">One. Two. Three. Four. Five.</div>

但不把這些時期放在其中:

<div class="spanish">Uno. Dos. Tres. Cuatro. Cinco.</div>

謝謝

如果只想選擇<div class="english"></div>之間的點,則可以使用:

(?:<div class="english">|(?!^)\G)(?:[^.<]|<(?!/div>))*\K\.

說明和演示

(?:                     # non-capturing group
  <div class="english"> # our delimiter
|                       # or
  (?!^)\G               # the end of the last match
)
(?:
  [^.<]               # any character except '.' or '<' (even newline)...
|                     # or ...
  <(?!/div>)          # '<' not followed by a '/div>'
)*
\K                    # leave what we found so far out of the match
\.                    # match the dot

有關\\K\\G的用法,請參見參考。

<div class="(?!english)[^"]*">.*?<\/div>\K|\.(?=.*?<\/div>)

您可以使用\\K執行此操作\\K參見演示。

https://regex101.com/r/cT0hV4/18

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM