简体   繁体   中英

Regular expression Notepad++ multiple replace?

Is there a way to perform multiple search and replace using Regular expresion? I have strings:

aaa
bbb
ccc

across the plain text, and I want to replace them

aaa to replace with ddd
bbb to replace with eee
ccc to replace with fff

Is there a regular expression to do that at once, using one single regex?

I am using Notepad++

https://notepad-plus-plus.org/community/topic/11385/how-to-multi-replace

The general syntax is:

Find: (FindA)|(FindB)|(FindC)...
Replace: (?1ReplaceA)(?2ReplaceB)(?3ReplaceC)...

Notes: Be sure that the Regular expression search mode is checked

For instance:

  • Find what: (aaa)|(ccc)|(eee)|(123)
  • Replace with: (?1bbb)(?2ddd)(?3fff)(?{4}456)

gives:

  • The string aaa is changed into bbb
  • The string ccc is changed into ddd
  • The string eee is changed into fff
  • The string 123 is changed into 456

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