Date: Fri, 16 Jul 2010 21:09:04 +0000
Reply-To: toby dunn <tobydunn@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: toby dunn <tobydunn@HOTMAIL.COM>
Subject: Re: prx matching "all the characters are the same"
In-Reply-To: <201007162044.o6GJJZV2006389@willow.cc.uga.edu>
Content-Type: text/plain; charset="iso-8859-1"
Chang,
Mine did match the 'aaaAAA' but I didn't think you wanted the Punctuation to. In that case its as simple as moving to a posix character class:
PrxMatch( '/^([[:graph:]])(?=\1*?\s*?$)/io' , Var )
Which I did run it and it does match both cases.
Toby Dunn
"Don't bail. The best gold is at the bottom of barrels of crap."
Randy Pausch
"Be prepared. Luck is where preparation meets opportunity."
Randy Pausch
> Date: Fri, 16 Jul 2010 16:44:52 -0400
> From: chang_y_chung@HOTMAIL.COM
> Subject: Re: prx matching "all the characters are the same"
> To: SAS-L@LISTSERV.UGA.EDU; tobydunn@HOTMAIL.COM
>
> On Thu, 15 Jul 2010 21:47:58 +0000, toby dunn <tobydunn@HOTMAIL.COM> wrote:
> ...
> >PrxMatch( '/^(\w)(?=\1*?\s*?$)/io' , Var )
>
> as a solution to my question at the bottom. Thanks a lot for trying! But
> unfortunately, your prx is still not quite correct. Try "aaAA" or "!!!!" as
> input. Dani's non-prx solution does handle these well.
>
> /* Dani^s non-prx solution */
> where countc(strip(var),substr(var,1,1))=length(var);
>
> Cheers,
> Chang
>
> ...
> >> Saw a similar question somewhere else today and wondering if it is
> possible
> >> with SAS as well. The challenge is to write a regex pattern to match a
> >> character variable where all the characters are the same, except
> missing. Is
> >> this possible?
> >> Cheers,
> >> Chang
> >>
> >> /* test data */
> >> data one;
> >> input var $10.;
> >> cards;
> >> aaaaabbbbb
> >> aaaaaaaa
> >>
> >> bb
> >> a
> >> ababa
> >> b a
> >> ;
> >> run;
> >>
> >> /* fill out the question marked prx pattern below */
> >> proc print data=one;
> >> where prxmatch(" ? ", var);
> >> run;
> >> /* lst output should be:
> >> Obs var
> >>
> >> 2 aaaaaaaa
> >> 4 bb
> >> 5 a
> >> */
_________________________________________________________________
The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail.
http://www.windowslive.com/campaign/thenewbusy?tile=multiaccount&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4 |