Replacing to the end of a line

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

Replacing to the end of a line

Postby estado3 » Thu Dec 07, 2006 6:04 pm

I am wondering if I had a line:

&sid97807080779
&sid75646567676
&sid57657956bfshhf

and I wanted to remove everything after &sid, how would I do this with the find and replace feature with regular expressions switched on.
User avatar
estado3
Newbie
 
Posts: 5
Joined: Thu Dec 07, 2006 12:00 am

Re: Replacing to the end of a line

Postby Bego » Fri Dec 08, 2006 7:13 am

UE 12, Perl/Unix style:

replace
(^\&sid).*$
with
$1

Don't forget CRLF after last line.

rds Bego
User avatar
Bego
Master
Master
 
Posts: 357
Joined: Wed Nov 24, 2004 12:00 am
Location: Germany

Re: Replacing to the end of a line

Postby Mofi » Fri Dec 08, 2006 11:01 am

For completion, the UltraEdit style regular expression for this job is:

Find What: %^(&sid^)*$
Replace With: ^1

Well, the ^( ^) in the search string could be also removed when the replace string contains &sid instead of ^1.

Or if &sid is not at start of every line:

Find What: &sid*$
Replace With: &sid
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4056
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Find/Replace/Regular Expressions

cron