
Using the search string ^.+?(word) would avoid making a replace changing nothing on a line starting with word.īut Perl regexp engine supports even more like a non matching lookahead. A ? after the multiplier makes the expression non greedy. It is possible to use a Perl regular expression using backreferences like with UltraEdit/Unix regexp engines using search string ^.*?(word) or ^.+?(word) for a non greedy or ^.*(word) or ^.+(word) for a greedy search and using \1 as replace string.Īs it can be seen here, the Perl regexp engine has a special syntax do define a multiplier like * (0 or more times) or + (1 or more times) greedy or non greedy. With the most powerful Perl regular expression engine there are many possibilities for this task. Note: The non greedy expression makes a replace also with word being at beginning of line although nothing is really replaced/removed. The greedy search expression would be ^.+(test).+ means 1 or more times. ) tags the word for the replace referenced by \1 as the word should be kept. * means any character except carriage return and line-feed 0 or more times non greedy. With the Unix regular expression engine the search string needs to be ^.*(word) and the replace string is \1. But line change indicator would mark that line nevertheless as being modified. ?+ means any character except the newline characters carriage return and line-feed 1 or more times.

The search string is non greedy which means * stops matching characters on first occurrence of word in a line.Ī greedy search expression matching everything up to last occurrence of word in a line would be %?+^(word^). ^) tags the word for the replace referenced by ^1 as the word should be kept without changing the case of any letter in word on running a case-insensitive replace. * means any character except carriage return and line-feed 0 or more times.Using the UltraEdit regular expression engine with a tagged regular expression the search string is %*^(word^) and the replace string is just ^1.


There is also help directly in Replace dialog by clicking on button for opening regular expression builder list (button with magnifying glass or triangle depending on version of UE). This can be most easily done in UltraEdit with a regular expression Replace All executed from top of the file or using advanced replace option Replace all is from top of file.Ĭlick on Help button in Replace dialog and follow the links to the pages explaining UltraEdit/Unix and Perl regular expression syntax.
