how to make $ acting like \p

Help with writing and playing macros

how to make $ acting like \p

Postby thomasm76 » Tue Aug 07, 2007 1:28 pm

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)?
User avatar
thomasm76
Basic User
Basic User
 
Posts: 19
Joined: Sun Jun 18, 2006 11:00 pm

Re: how to make $ acting like \p

Postby Mofi » Tue Aug 07, 2007 3:14 pm

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.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4042
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: how to make $ acting like \p

Postby pietzcker » Wed Aug 08, 2007 8:25 am

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?
User avatar
pietzcker
Master
Master
 
Posts: 241
Joined: Sun Aug 22, 2004 11:00 pm


Return to Macros