Replace exactely 5 times ^p

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

Replace exactely 5 times ^p

Postby honda » Wed Jan 25, 2006 8:39 am

Replace exactly 5 times ^p

Hello

I have a file who looks like this, and contains 2-100 blocks with each 5 lines.

name: winstdvm1;
server: winstdvm1;
scheduled backup: Enabled;
comment: ;
Save operations: ;

name: winstdvm2;
server: winstdvm2;
scheduled backup: Enabled;
comment: ;
Save operations: ;

I like that to have all 5 lines of the first block in one line. This can be done
by search: ^p and replace:

Problem is that if I' am doing this all ^p are appended to end of the line instead on in the five lines in first, second block.

It should look like this: (It should be 2 x one line)

name: winstdvm1;server: winstdvm1;scheduled backup:... Enabled;comment: ;Save operations: ;
name: winstdvm2;server: winstdvm2;scheduled backup:... Enabled;comment: ;Save operations: ;

I didn't found how to search only ex: ^p(5) only replace 5 lines. I don't know right syntax.

Somebody any idea ?

Thanks
User avatar
honda
Newbie
 
Posts: 2
Joined: Wed Jan 25, 2006 12:00 am

Re: Replace exactely 5 times ^p

Postby Mofi » Wed Jan 25, 2006 12:58 pm

The regular expression replace for this job in UltraEdit style is:

Find What: %^(name:*^)^p^(server:*^)^p^(scheduled*^)^p^(comment:*^)^p
Replace With: ^1^2^3^4

And in Unix style:
Find What: ^(name:.*)\p(server:.*)\p(scheduled.*)\p(comment:.*)\p
Replace With: \1\2\3\4
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4049
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Replace exactely 5 times ^p

Postby honda » Wed Jan 25, 2006 1:50 pm

Thanks a lot Mofi. It works!
honda
User avatar
honda
Newbie
 
Posts: 2
Joined: Wed Jan 25, 2006 12:00 am

Re: Replace exactely 5 times ^p

Postby mrainey56 » Wed Jan 25, 2006 3:48 pm

The regular expression replace for this job in UltraEdit style is:

Find What: %^(name:*^)^p^(server:*^)^p^(scheduled*^)^p^(comment:*^)^p
Replace With: ^1^2^3^4

And in Unix style:
Find What: ^(name:.*)\p(server:.*)\p(scheduled.*)\p(comment:.*)\p
Replace With: \1\2\3\4


Comparing these two, which accomplish exactly the same thing, is why I prefer the Unix style - just easier on my old eyes.
User avatar
mrainey56
Master
Master
 
Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina


Return to Find/Replace/Regular Expressions