UE32's replace function is very unreliable

Find, replace, find in files, replace in files, regular expressions

UE32's replace function is very unreliable

Postby tricky » Wed Apr 26, 2006 3:48 pm

Version 12 is a joke, so I don't want to mention it. This problem existed since long long ago. You can do an experiment yourself.

1. Turn on unix regular expression option.
2. Input 4 lines of text and move cursor to the beginning of file. It may look like this:

|111111111
2222222222
3333333333
4444444444

3. In replace dialog input like this:

Fine What: ^
Replace With: #

And click Start. (This means I want to put a # in the beginning of a line.)

4. In Replace dialog, click Replace. (Suppose I want to replace one by one) You will find UE miss some lines so the result may be like this:

#1111111111
2222222222
#3333333333
4444444444

I have reported this problem to IDM before. I don't why they just don't want to fix it.
User avatar
tricky
Newbie
 
Posts: 3
Joined: Tue Apr 25, 2006 11:00 pm

Re: UE32's replace function is very unreliable

Postby tricky » Fri Apr 28, 2006 1:39 am

Hi Mofi,

you said:

"I agree with you that searching for only "^" or only "$" and "replacing" it with a string should be possible and I have already written that it works with UltraEdit and legacy Unix style."

Actually, I think it still works not very well with legacy UNIX style. As my example, if you replace "^" with a string one by one (not Replace All), you will get an unexpected result. I believe there is something bad with UE's algorithm. If you have time, you can test the same case with other text editor which support unix regex, then you can tell how I feel. I used to work with UE a few years ago, but since I learned unix regex and found the problem with UE, I gave up UE finally.

In certain aspect, UE is a good editor. I use unix regex a lot during my work and I really hope IDM can fix this problem so I can trust it again.

BR,

tricky
User avatar
tricky
Newbie
 
Posts: 3
Joined: Tue Apr 25, 2006 11:00 pm

Re: UE32's replace function is very unreliable

Postby Mofi » Fri Apr 28, 2006 9:02 am

You are right. It's not working when executing it one by one. It fails also with UltraEdit style regular expression and I agree it is a bug.

But as explained already at the other forum topic, the ^ regexp character does not match a character, it's just a position statement. You misuse the replace command as insert in column mode command.

In such situations I switch to column mode with ALT+C, mark the lines with the cursor keys while holding the SHIFT key and press the # key to insert this character at the current column. ALT+C again to switch back to normal edit mode and I'm finished.

If you have a syntax highlighting for this type of file and the # is the line comment, you can also mark lines and use the Edit - Comment Add and Edit - Comment Remove functions (with hot keys for faster usage).

But if you really want to insert the # with a regular expression replace, use following regexp in Unix style:

Find: ^(.)
Replace: #\1

This will work on all lines except blank lines.

Or use following normal (not regexp) replace which works for all lines except the first line of the file if the file is a DOS file. Use ^n instead of ^p if you have an Unix file opened in Unix mode.

Find: ^p
Replace: ^p#
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4068
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Find/Replace/Regular Expressions