Re: bulky regex



On Wed, Apr 27, 2005 at 01:50:57PM -0400, Jay Savage wrote:
> You can drop the stuff from the end, too. If 'ups' is optional and
> the spacing is variable, then of course handle that with *
>
> $description =~
> s/\s*free\+(?:ups)*\s*ground\s+shipping\s*[!]*\s*//i; # or /ig if
> needed
>
> Rearrange to suit. But the imporant thing here is to go for what you
> need to replace, and not what you don't.


Mmm... as I wrote in the comments in the very first e-mail:
> blablabla...I want to keep the space if I am cutting from inside a string
Is there a way to do this without the lookahead? Yes I can replace with / /,
but then I am introducing more spaces than there were if I am at the
beginning or at the end...? Excuse my curiosity :)
.