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"
Content-Type: text/plain; charset="iso-8859-1"
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.
"Don't bail. The best gold is at the bottom of barrels of crap."
"Be prepared. Luck is where preparation meets opportunity."
> 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);
> >> Saw a similar question somewhere else today and wondering if it is
> >> 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.