- AuthorPosts
- December 30, 2007 at 7:26 am #5239ptlomholtParticipant
Something strange is going on with Find/Replace in Files when using some regular expressions.
To reproduce create a file, say file0.txt, with the following contents:
ABC
DEF
GHI
(note the leading space on each line) and save it to an empty folder. Now do “Find in Files…” using the following regular expression s*DEF, check the “Use Regular Expressions” checkbox, File Types: *.txt and select the folder with the file in.The search result is:
F:workzoneEmEditorfile0.txt(1): ABC
which obviously is incorrect! When doing “Replace in Files…” instead it _does_ replace the correct match (good).However using DEFn as the search expression doesn’t find anything and also doesn’t replace anything!
When doing the same Search or Replace using the simple Find/Replace command, everything works fine.
This was using the 7.0 Pro RTW build, both x86 and x64 versions exhibit this behavior
Any ideas?
Regards
-PoulDecember 30, 2007 at 7:42 am #5240Yutaka EmuraKeymasterptlomholt wrote:
Something strange is going on with Find/Replace in Files when using some regular expressions.
To reproduce create a file, say file0.txt, with the following contents:
ABC
DEF
GHI
(note the leading space on each line) and save it to an empty folder. Now do “Find in Files…” using the following regular expression s*DEF, check the “Use Regular Expressions” checkbox, File Types: *.txt and select the folder with the file in.The search result is:
F:workzoneEmEditorfile0.txt(1): ABC
which obviously is incorrect! When doing “Replace in Files…” instead it _does_ replace the correct match (good).However using DEFn as the search expression doesn’t find anything and also doesn’t replace anything!
When doing the same Search or Replace using the simple Find/Replace command, everything works fine.
This was using the 7.0 Pro RTW build, both x86 and x64 versions exhibit this behavior
Any ideas?
Regards
-PoulF:workzoneEmEditorfile0.txt(1): ABC
is correct because s* matches the new line characters “rn” between ABC and DEF, and the Find in Files result only shows the first line of the matched string.
You will need to use
DEFrn
to match a new line after DEF, or check “Use escape sequence” instead of “Use regular expressions”. I know this is a little strange specification, but see http://www.emeditor.com/help/howto/search/search_nl.htm
for details. - AuthorPosts
- You must be logged in to reply to this topic.