RegEx search and replace in Eclipse over multiple lines with start and middle and end -


i struggling come regex search , replace following case. doing migration richfaces 3 richfaces 4 , far able lot of changes regex.

i've got this:

     <a:ajax execute="@this"     rendered="whatever" action="#{bean.method}  someotherstuff="whatever"     /> 

what want replace action= listener= in above without changing else , want within a:ajax tag. order , occurrence of attributes can vary.

so need search , replace this:

<a:ajax(search1)action="(.+?)"(search2)/> 

replace

<a:ajax$1listener="$2"$3/> 

any ideas. think might need lookahead haven't worked yet

update: accepted solution work in eclipse searching there known bug in eclipse replace isn't working when use around: https://bugs.eclipse.org/bugs/show_bug.cgi?id=109481

if want replace action= listener= inside a:ajax tag need lookbehind instead of lookahead. , must note lookbehind in java means must define maximum length of lookbehind range.

something (?<=a:ajax[\w\w\n]{1,100})action=" range of wildcards between 1 until 100, can increase if want changing {1,100}.

you can do

.replaceall("(?<=a:ajax[\\w\\w\\n]{1,100})action=\"","listener=\"")

note regex lookbehind:

  • java allowing finite repetition. still cannot use star or plus, can use question mark , curly braces max parameter specified.
  • jgsoft engine , .net framework regex classes, can full regex inside lookbehind.
  • javascript not supported lookbehind.
  • python can use fixed length inside lookbehind.

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -