Multiple search & replace - Notepad ++ (regex) -


i have list of words, example:

 -> bad  sky -> blue  gray -> black 

etc...

what best why find&replace in notepad++? tried this:

find: (good)|(sky)|(gray)  replace: (?1bad)(?2blue)(?3black) 

but doesn't work :( idea? or suggestions ?

there workaround if add newline @ end of text (it must last line, don't press enter @ end):

#good:bad#sky:blue#gray:black# 

and if use pattern:

(good|blue|black)(?=(?:.*\r)++#(?>[^#]+#)*?\1:([^#]+))|\r.++(?!\r) 

with replacement:

$2 

pattern details:

(good|blue|black)  # part capture word in group 1 (?=                # reach last line in lookakead     (?:.*\r)++     # match lines until last line     #(?>[^#]+#)*?  # advance until value found      \1             # value (backreference capture group 1)     : ([^#]+)      # capture replacement in group 2 )                  # close lookbehind  |                  # or  \r.++(?!\r)        # match last line (to remove it) 

note: make pattern more efficient, can put in non capturing group , add lookahead @ begining first possible characters discard useless positions in string:

(?=[gb\r\n])(?:\b(good|blue|black)\b(?=(?:.*\r)++#(?>[^#]+#)*?\1:([^#]+))|\r.++(?!\r)) 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -