regex - How do I replace characters enclosed inside of two brackets in Notepad++? -


in notepad++, how can replace character (.) enclosed within 2 brackets [] throughout large file?

explanation

i have long code dump file (of peoplecode) in notepad++. @ top of each section of code, there tag this:

[g3form.formfactory.onexecute] 

this denotes class package, , class. in addition, can multiple layers deep:

[y_rest.restqueries.exampleclass.onexecute] 

whenever class declared in code, doesn't use .'s. uses :'s. e.g.:

import g3form:form; 

so, when want search class in code dump, have change of .'s :. can that, it's annoying.

example

i notepad++'s regex search feature find , replace. need replace of .'s contained within these headers :'s. e.g.:

[y_rest.restqueries.exampleclass.onexecute] 

would become

[y_rest:restqueries:exampleclass.onexecute] 

all last colon replaced (and then, if makes overly complicated, last . can replaced).

failed attempts

i have been playing around regex try , this, not familiar enough it.

this doesn't work @ all:

(([a-z])\.)+ 

this doesn't find anything:

\[(([a-z])\.)+\] 

i'm way off base. haven't used regex enough familiar enough know how use find , replace regex.

do regular expression find/replace this:

  • open replace dialog
  • find what: (\[[^\].]+)\.([^\]]+\])
  • replace with: \1:\2
  • check regular expression
  • click replace or replace all
  • keep alt-a (replace all) pressed until message in find dialogs status bar tells "0 occurences replaced"

Comments