Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #5239

    ptlomholt
    Participant

    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
    -Poul

    #5240

    Yutaka Emura
    Keymaster

    ptlomholt 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
    -Poul

    F: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.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.