Re: bulky regex
- From: rabbit@xxxxxxxxx (Peter Rabbitson)
- Date: Wed, 27 Apr 2005 12:20:58 -0500
On Wed, Apr 27, 2005 at 12:16:05PM -0500, Peter Rabbitson wrote:
> description =~ s/ #take away free ground shipping text
>
> (?: #non-capturing block for | inclusion
> (^) #start of string
> | #or
> (?<=\S) #lookbehind non-space character
> )
>
> \s* #maybe some spaces
> free #word 'free'
> \s+ #at least one space
> (?:ups\s+)? #non-capturing 'ups' with at least one trailing space
> ground #'ground'
> \s+ #spaces
> shipping #'shipping'
> \s* #maybe some spaces
> !* #maybe some exclamation marks
> \s* #maybe some more spaces
>
> (?: #non-capturing for | inclusion
> ($) #end of string
> | #or
> (?=\S\s?) #lookahead non-space character maybe followed by a space (I want to keep the space if I am cutting from inside a string)
> )
>
> //ixg; #replace with nothing
Ops. (?=\S\s?) above should be (?=\s\S), if it's not at the end of a
string I am guaranteed at least a single space, sorry about that.
.
- References:
- bulky regex
- From: Peter Rabbitson
- bulky regex
- Prev by Date: bulky regex
- Next by Date: Re: bulky regex
- Previous by thread: bulky regex
- Next by thread: Re: bulky regex
- Index(es):
Relevant Pages
|