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 (June 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 17 Jun 2008 23:37:08 -0600
Reply-To:     Richard Read Allen <peakstat@WISPERTEL.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Richard Read Allen <peakstat@WISPERTEL.NET>
Subject:      Re: Regular expressions
Comments: To: toby dunn <tobydunn@HOTMAIL.COM>
In-Reply-To:  <BAY123-W38F99B1CDB326078110480DEAB0@phx.gbl>
Content-Type: text/html; charset=windows-1252

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=windows-1252" http-equiv="Content-Type"> <title></title> </head> <body bgcolor="#ffffff" text="#000000"> Toby,<br> <br> Thanks for the suggestion. This works for these examples however the problem I'm facing is more complicated than this. I've got a string of up to 2000 characters with 1s and 0s and need to search the whole string for each occurrence of 10...01, where the string of 0s is 1 or more and less than or equal than 31 and replace it with 1X...X1. Can a regular expression be written to do this?<br> <br> <tt>have- 11110000111111000000000000000000000000000000000111111000000000000000000011111111111110111111<br> want- 1111XXXX111111000000000000000000000000000000000111111XXXXXXXXXXXXXXXXXXX1111111111111X111111<br> </tt><br> Thanks,<br> <br> Richard<br> <br> toby dunn wrote: <blockquote cite="mid:BAY123-W38F99B1CDB326078110480DEAB0@phx.gbl" type="cite"> <pre wrap="">Data _Null_ ; Length X $ 10 ; Do X = '1' , '10' , '101' , '1001' , '10001' , '100001' , '1000001' ; X = PrxChange( 's/0/X/o' , -1 , Strip(X) ) ; Put X= ; End ;

Run ;

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

</pre> <blockquote type="cite"> <pre wrap="">Date: Tue, 17 Jun 2008 22:27:44 -0600 From: <a class="moz-txt-link-abbreviated" href="mailto:peakstat@WISPERTEL.NET">peakstat@WISPERTEL.NET</a> Subject: Regular expressions To: <a class="moz-txt-link-abbreviated" href="mailto:SAS-L@LISTSERV.UGA.EDU">SAS-L@LISTSERV.UGA.EDU</a>

I'm new to Perl regular expressions and am trying to create one to perform the following replacements:

101=1X1 1001=1XX1 10001=1XXX1

etc., replacing up to 31 consecutive "0" with "X". Is this possible?

Thanks,

Richard </pre> </blockquote> <pre wrap=""><!----> _________________________________________________________________ The i’m Talkathon starts 6/24/08. For now, give amongst yourselves. <a class="moz-txt-link-freetext" href="http://www.imtalkathon.com?source=TXT_EML_WLH_LearnMore_GiveAmongst">http://www.imtalkathon.com?source=TXT_EML_WLH_LearnMore_GiveAmongst</a>

</pre> </blockquote> </body> </html>


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