LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (August 2011, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 23 Aug 2011 19:25:29 +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: Regular expression repetition factor {n,m}
Comments: To: rhoadsm1@westat.com
In-Reply-To:  <D47ACC3DC1D6CA4D85DE61DC39DA319F062F32F4@EX10MAIL2.westat.com>
Content-Type: text/plain; charset="Windows-1252"

Mike, No clue why the rx functions doesnt work but will say they are depricated and SAS favors the Prx functions. So much so that I am not even writing or mentioning them in my book. So my advice is to just add a p: data _null_; rx = prxparse("/\d+/"); rx = prxparse("/\d*/"); rx = prxparse("/\d{3}/"); rx = prxparse("/\d{1,3}/"); run;

And if it was me Id add one more to your list: rx = prxparse( "/\d\d\d/" ) ; You can gain some optimization by skipping the quantifier and just specifying the number of metasequences you want, this limits some overhead from the RegEx engine that is needed with quantifiers. and you might want to add: rx = prxparse( "/\d\d?\d?/" ) ; to match the last example. or perhaps rx = prxparse( "/\d?/" ) ; As ? is a quantifier along with the +, *, {N,M}.

Toby Dunn

If you get thrown from a horse, you have to get up and get back on, unless you landed on a cactus; then you have to roll around and scream in pain. “Any idiot can face a crisis—it’s day to day living that wears you out” ~ Anton Chekhov

> Date: Tue, 23 Aug 2011 19:17:36 +0000 > From: RHOADSM1@WESTAT.COM > Subject: Regular expression repetition factor {n,m} > To: SAS-L@LISTSERV.UGA.EDU > > OK, the U.S. east coast earthquake has obviously addled my brain. > > data _null_; > rx = rxparse("/\d+/"); > rx = rxparse("/\d*/"); > rx = rxparse("/\d{3}/"); > rx = rxparse("/\d{1,3}/"); > run; > > The first 3 of these compile the regular expression just fine, but for the final one, I get the following error message in the log: > > ERROR: The following pattern expression passed to the function RXPARSE contains a syntax error. > /\d{1,3}/ > ^ > ERROR: Need a symbol to close an optional subexpression. > > I am certainly not an RX expert, but according to the documentation, this sure looks OK to me (SAS 9.2 TS2M3, WinXP). > > Thanks! > > > Mike Rhoads > RhoadsM1@Westat.com


Back to: Top of message | Previous page | Main SAS-L page