maithree has asked for the wisdom of the Perl Monks concerning the following question:
I trying to do some replacing stuff like:
Search for repeated occurrences of a character at the end of a string and replace it with half the number of characters. It is assumed that it is always a multiple of 2.
We can match on n number of occurences with something like
Is there something similar for replacing, something like...s/(pattern+$){n}/g;
The value of n is not fixed and so I cannot harcode it in the command.s/(pattern+$){n}/(pattern){n/2}/g;
Is there any simple search/replace command that I can use to achieve this ?
Thanks.
update (broquaint): added formatting
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Replacing with multiple occurrences.
by broquaint (Abbot) on May 08, 2003 at 10:52 UTC | |
|
Re: Replacing with multiple occurrences.
by strat (Canon) on May 08, 2003 at 11:00 UTC | |
|
Re: Replacing with multiple occurrences.
by Skeeve (Parson) on May 08, 2003 at 11:23 UTC | |
by perlguy (Deacon) on May 08, 2003 at 16:02 UTC | |
|
Re: Replacing with multiple occurrences.
by perlguy (Deacon) on May 08, 2003 at 15:55 UTC | |
by physi (Friar) on May 08, 2003 at 16:32 UTC | |
by Skeeve (Parson) on May 09, 2003 at 06:37 UTC |