in reply to Variable-width negative lookbehind
If the first character is 'Y', you want to remove all X's from index 2 on, otherwise remove them from index 1 on. That's a job for tr///d, and substr:
TIMTOWTDI.substr( $string, substr($string,0,1) eq 'Y' ? 2 : 1) =~ tr/X//d;
Update: Or more succinctly, with $_, substr( $_, /^Y/ ? 2 : 1) =~ tr/X//d;
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Variable-width negative lookbehind
by Roy Johnson (Monsignor) on May 05, 2004 at 20:17 UTC | |
|
Re: Re: Variable-width negative lookbehind
by japhy (Canon) on May 05, 2004 at 19:56 UTC |