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 2007, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 30 Aug 2007 13:12:01 +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: regex challenge
Comments:   To: rune@FASTLANE.NO
In-Reply-To:   <HoidnWQ3oaygHkvb4p2dnAA@telenor.com>
Content-Type:   text/plain; format=flowed

Rune ,

Screw the Perl RegEx you already gave all you need iin SAS functions which work faster than RegEx in simple cases like these:

Data Need1 Need2 ; Set Have ;

If ( Verify( String , '0' ) = 0 ) Then Output Need1 ;

Else If ( String =: '0' ) Or ( Substr( String , 2 , 1 ) = '0' ) Then Output Need2 ; Run ;

Toby Dunn

Comprimise is like telling a lie, it gets easier and easier. Each comprimise you make, that becomes your standard.

Perfection doesnt exist, once you reach it, its not perfect anymore. It means something else.

From: Rune Runnestø <rune@FASTLANE.NO> Reply-To: Rune Runnestø <rune@FASTLANE.NO> To: SAS-L@LISTSERV.UGA.EDU Subject: regex challenge Date: Thu, 30 Aug 2007 10:43:33 +0200

Hi, I am trying to accomplish two things. First, I want to pick up the records where alle the signs in STRING are zeros. Second, I want to pick up records where the first and/or the second sign are zeros, but where the rest of STRING does *not only* contain '0'. I will create a data set for each purpose. The dataset MYDS1 is an attempt to solve the first task with a regex, but it doesn't work. It picks up all 4 records.

The dataset MYDS2 is an attempt to solve the second task, but there too all 4 records are picked up.

Does anyone see a solution to those tasks ? Doesn't necessarily have to be done by a regex, but why not ?

Regards, Rune

data myds1; if _n_ = 1 then re = prxparse('/[^1-9]/'); retain re; input string $char11.; if prxmatch(re, string) gt 0 then output; datalines; 00974243741 00000000000 00966707674 00000000000 run;

data myds2; if _n_ = 1 then re = prxparse('/(0|00)[^1-9]/'); retain re; input string $char11.; if prxmatch(re, string) gt 0 then output; datalines; 00974243741 00000000000 00966707674 00000000000 run;

_________________________________________________________________ Puzzles, trivia teasers, word scrambles and more. Play for your chance to win! http://club.live.com/home.aspx?icid=CLUB_hotmailtextlink


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