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 (December 2005, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 6 Dec 2005 21:51:43 -0800
Reply-To:     Dale McLerran <stringplayer_2@YAHOO.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Dale McLerran <stringplayer_2@YAHOO.COM>
Subject:      Re: Wild card equivalent in SAS ?
In-Reply-To:  <BAY103-F203C9CA47D3681525699C2B0430@phx.gbl>
Content-Type: text/plain; charset=iso-8859-1

--- David L Cassell <davidlcassell@MSN.COM> wrote:

> stringplayer_2@YAHOO.COM replied: > >David Cassell will undoubtedly offer up a Perl regular > >expression (PRX??? function) which will accomplish the > >identification and replacement all implemented in a single > >call routine. It will be very elegant, but if you don't > >know PRX functions, it will take you the better part of > >a week to figure out just how the function works. > > I'm hurt. I thought that my PRX posts were as clear as water. :-) > :-) > > If our poster has 9.1, he can stuff the regex inside the PRXMATCH() > function > and do this in one line of UNTESTED code: > > if prxmatch('/mening\.\w+\.W135/', VarToBeChecked); > > > Now isn't that simple? The regex inside the forward slashes says: > > mening the letters 'mening' > \. a real period > \w+ one or more 'word' characters: A-Z, a-z, 0-9, or _ > \. another real period > W135 the sequence 'W135' > > I personally prefer some error checking. The below code works as > long as > you have > SAS 9: > > > data newstuff; > retain re; > set oldstuff; > if _n_=1 then do; > re = prxparse('/mening\.\w+\.W135/'); > if missing(re) then do; putlog 'ERROR: evil regex loose!'; stop; > end; > end; > if prxmatch(re, VarToBeChecked); > run; >

I tossed David a lazy fastball with no movement on the pitch and he belted it out of the park. But let's see what he can do with a curve ball.

Suppose that the text between 'mening.' and '.W135' contains characters other that a-z, A-Z, 0-9, and _. The original poster did not indicate that TEXT was just digits and/or letters of the alphabet. Suppose that TEXT contains some parentheses or commas or periods. The w+ will not match those characters, so we would miss lines like

mening.().W135 mening.123.4.W135

Is there a simple wild card structure which would match all characters that appeared between 'mening.' and '.W135'?

Dale

--------------------------------------- Dale McLerran Fred Hutchinson Cancer Research Center mailto: dmclerra@NO_SPAMfhcrc.org Ph: (206) 667-2926 Fax: (206) 667-5977 ---------------------------------------

__________________________________________ Yahoo! DSL Something to write home about. Just $16.99/mo. or less. dsl.yahoo.com


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