Is it possible to remove 2nd or 3rd occurence of some string

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

Is it possible to remove 2nd or 3rd occurence of some string

Postby marino » Fri Jan 07, 2005 11:06 pm

Hi
1) For example how to remove/replace 3rd occurence of ":" with "xx"
aaaa:bbbb:cccc:dddd:eeee - it means between cccc and dddd - of course words will not have the same lenght.
2) how to remove dddd and replace it with lets say xxxxxxxxx - the point is to replace something after 3rd ":" not to search for dddd because I want to replace all words after 3rd ":" but before 4th ":"in all lines.
I am interesting only how to do it with regular expressions if possible
Thank You very much.
User avatar
marino
Newbie
 
Posts: 9
Joined: Fri Dec 31, 2004 12:00 am

Re: Is it possible to remove 2nd or 3rd occurence of some st

Postby Mofi » Mon Jan 10, 2005 3:46 am

Regular expressions in UltraEdit style!

1) Search for %^(*:*:*^): and replace it with ^1??.
?? is simply nothing, if you want to remove the 3rd ':', or "xx", if you want to replace it.

2) Search for %^(*:*:*:^)*: and replace it with ^1??:.
?? is the new word.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4066
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Is it possible to remove 2nd or 3rd occurence of some st

Postby marino » Tue Jan 11, 2005 8:20 am

Thanks
User avatar
marino
Newbie
 
Posts: 9
Joined: Fri Dec 31, 2004 12:00 am


Return to Find/Replace/Regular Expressions