简体   繁体   中英

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

Using Regex in Notepad++, how do I select only the period inside these lines:

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

but leaving alone the period inside these ones:

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

Thanks

If you want to select only the dots between <div class="english"> and </div> you can use:

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

Explanation and demo :

(?:                     # 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

See reference for the use of \\K and \\G .

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

You can do this using \\K .See demo.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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