Date: Fri, 9 Nov 2007 11:01:37 -0600
Reply-To: Yu Zhang <zhangyu05@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Yu Zhang <zhangyu05@GMAIL.COM>
Subject: Re: Regex solution needed.
In-Reply-To: <8C9F10632AFC0FC-A44-2E72@FWM-M37.sysops.aol.com>
Content-Type: text/plain; charset=ISO-8859-1
Ken,
Yes, your Regex is working well. in my follow-up message, i forgot to
mention that I want to extract the whole word after the match is
found. the goal actually is changed. sorry I was in my own world and
didn't make things clear enough. I appreciated your help.
Good Day!
Yu
On Nov 9, 2007 10:39 AM, <evilpettingzoo97@aol.com> wrote:
> Yu,
>
> ... in which case my revised regex should be OK, as opposed to the one you
> augmented. That is, unless, the spec changes.
>
> Have a nice weekend!
> Ken
>
>
>
>
> -----Original Message-----
> From: Yu Zhang <zhangyu05@gmail.com>
> To: evilpettingzoo97@aol.com
> Sent: Fri, 9 Nov 2007 11:36 am
> Subject: Re: Regex solution needed.
>
> You are right. the capturing is not needed. Thanks!
>
>
>
> Yu
>
>
>
> On Nov 9, 2007 10:03 AM, <evilpettingzoo97@aol.com> wrote:
>
> > Yu,
>
> >
>
> > I think you can skip the 'capturing' part. If the regex finds a match,
> then
>
> > POS>0 and just assign STRING to POS.
>
> >
>
> > if pos then match = string;
>
> >
>
> > regards,
>
> > Ken
>
> >
>
> >
>
> >
>
> > -----Original Message-----
>
> > From: Yu Zhang <zhangyu05@GMAIL.COM>
>
> > To: SAS-L@LISTSERV.UGA.EDU
>
> >
>
> > Sent: Fri, 9 Nov 2007 10:49 am
>
> > Subject: Re: Regex solution needed.
>
> >
>
> >
>
> >
>
> > Thanks Ken. Everything looks fine until i add word 'Wouldn't' for
>
> >
>
> > testing. the Regex matched 't'. this make me thinking that we may need
>
> >
>
> > to regex to handle the apostrophe. in order to match the whole word we
>
> >
>
> > have to consume it instead of looking for its existence. I put yours
>
> >
>
> > and mine together and make it like,
>
> >
>
> >
>
> >
>
> > "/(\b(\w+)(?<!s)\b)|(\b(\w+'\w+)\b(?<!s))/i"
>
> >
>
> >
>
> >
>
> > it seems works so far. maybe this is not a situation where the Regex
>
> >
>
> > is perfectly fit. I really appreciate your solution and thoughts.
>
> >
>
> >
>
> >
>
> > Good weekend!
>
> >
>
> >
>
> >
>
> > Yu
>
> >
>
> >
>
> >
>
> > On Nov 8, 2007 9:06 PM, Ken Borowiak <EvilPettingZoo97@aol.com> wrote:
>
> >
>
> > > Yu,
>
> >
>
> > >
>
> >
>
> > > Upon further review, just a negative lookahead will not do. This one
>
> > should
>
> >
>
> > > get the job done. I added more obs to check for robustness.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > data test;
>
> >
>
> > > if _n_ = 1 then re = prxparse("/\b(\w+(?!')\b)(?<!s)/i");
>
> >
>
> > > retain re;
>
> >
>
> > > infile cards truncover;
>
> >
>
> > > input string $20.;
>
> >
>
> > >
>
> >
>
> > > pos=prxmatch(re, string);
>
> >
>
> > > if pos then match = prxposn(re, 1, string);
>
> >
>
> > > cards;
>
> >
>
> > > john's
>
> >
>
> > > book
>
> >
>
> > > JOHNS
>
> >
>
> > > bike
>
> >
>
> > > Jim
>
> >
>
> > > James
>
> >
>
> > > James'
>
> >
>
> > > crayon
>
> >
>
> > > ;
>
> >
>
> > > run;
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > This regex looks for a 'word', but uses a negative lookahead to assert
>
> > the
>
> >
>
> > > end boundary of the word is not an apostrophe('). Then it uses a
> negative
>
> >
>
> > > lookbehind to assert the last character is not an 's'.
>
> >
>
> > >
>
> >
>
> > > HTH,
>
> >
>
> > > Ken
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > On Thu, 8 Nov 2007 16:54:47 -0600, Yu Zhang <zhangyu05@GMAIL.COM>
> wrote:
>
> >
>
> > >
>
> >
>
> > > >Hi, Alan,
>
> >
>
> > > >
>
> >
>
> > > >Thank you for your solution. I didn't make it clear that I want to
>
> >
>
> > > >find a word not ending with 's'. the 'john's' is a specical case
>
> >
>
> > > >ending with 's', but i can not come up with a correct Regex not
>
> >
>
> > > >picking it up.
>
> >
>
> > > >
>
> >
>
> > > >Thanks!
>
> >
>
> > > >
>
> >
>
> > > >Yu
>
> >
>
> > > >
>
> >
>
> > > >On Nov 8, 2007 4:36 PM, Alan Churchill <savian001@gmail.com> wrote:
>
> >
>
> > > >> [a-zA-Z']+s
>
> >
>
> > > >>
>
> >
>
> > > >> Tested using RegexBuddy.
>
> >
>
> > > >>
>
> >
>
> > > >> Alan
>
> >
>
> > > >>
>
> >
>
> > > >> Alan Churchill
>
> >
>
> > > >> Savian
>
> >
>
> > > >> www.savian.net
>
> >
>
> > > >>
>
> >
>
> > > >>
>
> >
>
> > > >>
>
> >
>
> > > >> -----Original Message-----
>
> >
>
> > > >> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
>
> > Yu
>
> >
>
> > > >> Zhang
>
> >
>
> > > >> Sent: Thursday, November 08, 2007 3:19 PM
>
> >
>
> > > >> To: SAS-L@LISTSERV.UGA.EDU
>
> >
>
> > > >> Subject: Re: Regex solution needed.
>
> >
>
> > > >>
>
> >
>
> > > >>
>
> >
>
> > > >> sorry I posted a wrong testing code. this is what i am tring to
> show,
>
> >
>
> > > >>
>
> >
>
> > >
>
> >
>
> > > >> thanks!
>
> >
>
> > > >>
>
> >
>
> > > >> Yu
>
> >
>
> > > >>
>
> >
>
> > > >> data test;
>
> >
>
> > > >> if _n_ = 1 then re = prxparse('/\b(\w*(?<!s))\b/');
>
> >
>
> > > >>
>
> >
>
> > > >> retain re;
>
> >
>
> > > >> infile cards truncover;
>
> >
>
> > > >> input string $20.;
>
> >
>
> > > >>
>
> >
>
> > > >> pos=prxmatch(re, string);
>
> >
>
> > > >> if pos then match = prxposn(re, 1, string);
>
> >
>
> > > >> cards;
>
> >
>
> > > >> john's
>
> >
>
> > > >> book
>
> >
>
> > > >> ;
>
> >
>
> > > >> run;
>
> >
>
> > > >>
>
> >
>
> > > >>
>
> >
>
> > >
>
> >
>
> >
>
> >
>
> >
>
> > ________________________________
>
> > Email and AIM finally together. You've gotta check out free AOL Mail!
>
> >
>
>
> ________________________________
> Email and AIM finally together. You've gotta check out free AOL Mail!
>
|