Re: bulky regex



On 4/27/05, Peter Rabbitson <rabbit@xxxxxxxxx> wrote:
> On Wed, Apr 27, 2005 at 01:31:08PM -0400, Jay Savage wrote:
> >
> > Don't make things so complicated. You want to find some words and
> > replace them with nothing. You don't care where in the string the
> > pattern appears. Therefore, you don't have to predict where in the
>
> The word 'ups' is not mandatory - it might be there, might not. Also the
> amount of spaces inbetween is not fixed. However what you said about me not
> caring where the string is - you are right. I dropped (?:(^)|(?<=\S)) from
> the front, and it produces identical results. Thanks!
>

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.

HTH,

--jay
.



Relevant Pages

  • Re: post to an alternate non dot.net page
    ... WebClient myWebClient = new WebClient; ... // Apply ASCII Encoding to obtain the string as a byte array. ... but i'm not integrating with UPS. ... windows that on post back will open a new window, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: format line wrap?
    ... Take a long string and wrap it into a block of lines. ... I care as much about your client as you do care about my feeble ... Quis aute iure reprehenderit in ... voluptate velit esse cillum dolore eu ...
    (comp.lang.lisp)
  • Re: grep is too slow...
    ... JM> # on next line, we only care about $ortho, the orthographic string ... you are searching. ...
    (perl.beginners)
  • Re: Airline lost Rifle
    ... ship your gun via UPS to yourself, care of your outfitter, uncle George or ... whomever you will be hunting with. ... the difference between boxes shipped by UPS compared to most passenger ... UPS takes care of their baggage because it's their livelihood; ...
    (rec.hunting)
  • Re: Product received damaged - customer service, am I seriously asking too much here??
    ... that the shipper also didnt notice the crack either. ... damage, and received back this: "Put a claim in with UPS. ... take care of it. ...
    (rec.games.pinball)