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 2010, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 6 Aug 2010 19:12:28 +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: What do we have to do to SAVE SAS-L
Comments: To: lionel.teed@td.com
In-Reply-To:  <7A211600F7953A4B84F17813455504CB147544E9F7@EX7T2-SV02.TDBFG.COM>
Content-Type: text/plain; charset="iso-8859-1"

Lionel, My meds are more along the lines of pass me a Shiner Beer...Currently Im sitting here jamming out to some serious honky tonk music..... Sing on brother Aaron Watson As for the RegEx: 1.) If a space between the two parts are optional then: Data Want ; Set Have ; Position = PRXMatch( '/ [a-z]\d[a-z] *\d[a-z]\d ) ; Run ;

If there is a restriction on the letter in the first position we have to pull out some trickery... Unfortunantly there isn't an And operator like there is in Java, In java you could simply do: Position = PRXMatch( '/ (?:[[A-Z]&&[^DIOQU]]\d[A-Z] *\d[a-z]\d) /io' , String ) ; Which says match the first character with any letter a-zA-Z except dioquDIOQU. But we do have a look ahead ie. (?=), since it is a zero assertion creature it does not consume a thing.... which means we can look at a character, see if it is a-z and if it is then try to match it with a negated character class. Position = PRXMatch( '/ (?=[a-z])[^duioq]\d[A-Z] *\d[a-z]\d /io' , String ) ; Also notice the /io modifers, i = case insensitive and o = compile only once. Both are very handy to learn. The (?:....) are called non-capturing grouping, saves on memory usage.

Toby Dunn

"I'm a hell bent 100% Texan til I die"

"Don't touch my Willie, I don't know you that well"

> Date: Fri, 6 Aug 2010 14:06:42 -0400 > From: Lionel.Teed@TD.COM > Subject: Re: What do we have to do to SAVE SAS-L > To: SAS-L@LISTSERV.UGA.EDU > > Well... > > My thanks to both Toby and Art for the solutions provided. Toby's link's were very helpful. Art, as a fellow Canadian, provided a truly customized solution designed to identify the unique 'gotchas' inherent in the Canadian Postal Code numbers. > > Even Santa's postal code, H0H0H0 would be captured by the solution! > > > > > Lionel > > -----Original Message----- > From: Arthur Tabachneck [mailto:art297@NETSCAPE.NET] > Sent: Friday, August 06, 2010 1:10 PM > To: SAS-L@LISTSERV.UGA.EDU; Teed, Lionel > Subject: Re: What do we have to do to SAVE SAS-L > > Lionel, > > Toby is definitely more well versed than I am regarding regular > expressions, but I'd think that you have to account for both "ANANAN" > and "ANA NAN". There might be an easier way to state it, but the > following will find both: > > data have; > informat string $35.; > input string &; > cards; > 123 e north street toronto MMMJJJ > 123 s east street toronto LLLKKK > 123 e north street toronto M2J 5B5 > 123 s east street toronto L3T 5K9 > 123 e north street toronto M2J5B5 > 123 s east street toronto L3T5K9 > ; > > data want; > set have; > if _n_ eq 1 then do; > Pattern1 = "[ABCEGHJ-NPRSTVXYZ]\d[A-Z]* \d[A-Z]\d"; > Pattern2 = "[ABCEGHJ-NPRSTVXYZ]\d[A-Z]\d[A-Z]\d"; > patternID = > prxparse("/" !! Pattern1 !! "|" !! Pattern2 !! "/"); > end; > retain patternID; > position=prxmatch(patternID,string); > run; > > Art > ---------- > On Fri, 6 Aug 2010 13:30:31 +0000, toby dunn <tobydunn@HOTMAIL.COM> wrote: > > >Lionel, > > > >Much would depend on what all else is in your string. But lets assume > the following: > > > >1.) the beggining and ending of the postal code is seperated from the > other 32 characters by a space > >2.) the pattern you are looking for follows the Canadian postal code > schema of [char][digit][char][space][digit][char][digit] > > > > > >'/(?: [a-z]\d[a-z] \d[a-z]\d )/io' > > > >You might be able to get away with using the zero assertion \b to denote > the beggining and ending of your pattern string > >'/(?:\b[a-z]\d[a-z] \d[a-z]\d\b)/io' > > ******************** > NOTICE OF CONFIDENTIALITY > This communication including any information transmitted with it is > intended only for the use of the addressees and is confidential. > If you are not an intended recipient or responsible for delivering > the message to an intended recipient, any review, disclosure, > conversion to hard copy, dissemination, reproduction or other use > of any part of this communication is strictly prohibited, as is the > taking or omitting of any action in reliance upon this communication. > If you receive this communication in error or without authorization > please notify us immediately by return e-mail or otherwise and > permanently delete the entire communication from any computer, > disk drive, or other storage medium. > > If the above disclaimer is not properly readable, it can be found at > www.td.com/legal > > AVERTISSEMENT DE CONFIDENTIALITE > Ce courriel, ainsi que tout renseignement ci-inclus, destiné uniquement > aux destinataires susmentionnés, est confidentiel. Si vous > n'êtes pas le destinataire prévu ou un agent responsable de la > livraison de ce courriel, tout examen, divulgation, copie, impression, > reproduction, distribution, ou autre utilisation d'une partie de ce > courriel est strictement interdit de même que toute intervention ou > abstraction à cet égard. Si vous avez reçu ce message par erreur ou > sans autorisation, veuillez en aviser immédiatement l'expéditeur par > retour de courriel ou par un autre moyen et supprimer immédiatement > cette communication entière de tout système électronique. > > Si l'avis de non-responsabilité ci-dessus n'est pas lisible, vous > pouvez le consulter à www.td.com/francais/legale


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