ultraedit - UE Replace In Files with Regular Expressions and the 'any characters' ( * ) character -


i'm using ultraedit's (on mac) find , replace in files regular expressions clean sql server code blocks in multiple files. , noticing find in files outputs expected result, replace in files not make replaces expected.

for example, convert lower case case-when-then blocks upper case case-when-then:

screen shot of replace in files window search , replace string

find in files

case*when*then correctly finds line:

case when a1c.optimum = 1 , ldl.optimum = 1 , sbp.optimum = 1 , dbp.optimum = 1 then 1 else 0 end optimum,

replace in files

case*when*then case*when*then results line above in following line when , then not replaced expected upper case words:

case*when*then 1 else 0 end optimum,

what wrong on replace in files?

you using ultraedit regular expression engine * matches character except newline characters 0 or more times.

you have use tagged regular expression keep parts of found strings unmodified.

search string: case^(*^)when^(*^)then

replace string: case^1when^2then

the same replace using unix or perl regular expression engine:

search string: case(.*)when(.*)then

replace string: case\1when\2then

see perl regular expression using backreferences idm power tips explanation.

by way: better perl regular expression engine:

search string: \bcase\b(.*?)\bwhen\b(.*?)\bthen\b

replace string: case\1when\2then

\b means word boundary , therefore case, when , then must entire words , not 3 strings each exist anywhere within word.


Comments