how to make $ acting like \p

how to make $ acting like \p

19
Basic UserBasic User
19

    Aug 07, 2007#1

    Hello,

    My macro should run on files of every system (and hence different line terminators). Because of that reason I turned "automatic conversion to DOS" in UEs options on, but that leads to a crash when opening the file by "Open"-Command (see my previous post)

    Code: Select all

    Find MatchCase RegExp "^the matching text\p"
    Replace All ""
    works well on DOS-Files only (\p is the DOS-terminator).

    So I tried using $ instead of \p, but the problem ist that the line-terminator itself is not replaced like with \p. That leads to "empty lines" instead of a total replace of the line.

    What is the best solution of replacing the line-terminator too (for MAC, UNIX and DOS systems with the same macro)?

    6,606548
    Grand MasterGrand Master
    6,606548

      Aug 07, 2007#2

      For UNIX and DOS files the expression \r*\n could maybe used with Unix/Perl regex engine. For the UltraEdit engine the same expression is: ^r++^n . But that will fail on MAC files.

      But I have not tested any of these expressions. I use the automatically to DOS configuration setting and so my macros always work with ^p (UE style).

      I guess, your UNIX file is very large and that is causing the crash on open from within the macro because the macro continues before all threads on file open are executed. The same problem exists also for the script environment.
      Best regards from an UC/UE/UES for Windows user from Austria

      236
      MasterMaster
      236

        Aug 08, 2007#3

        You can use \r?\n?. Of course, you need to put this behind the $, so search for (Perl regex style) ^the matching text$\r?\n? and replace with nothing.

        If your data is such that the regex matches on consecutive lines, you should use (?:^the matching text$\r?\n?)+ instead.

        I don't have any MAC files around, but DOS and UNIX files work.

        HTH, Tim

        Quiz for bonus points: Why is ^the matching text\r?\n? a bad regex?