Date: Tue, 23 May 2006 19:04:49 -0600
Reply-To: Alan Churchill <SASL001@SAVIAN.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Alan Churchill <SASL001@SAVIAN.NET>
Subject: Re: How to use Perl Regular expressions
In-Reply-To: <000c01c67ec8$a80de640$f829b2c0$@net>
Content-Type: text/plain; charset="US-ASCII"
I forgot to add the explanation for the regex:
(?<=^\w+\s{3,})(\b.+$)
(\b.+$) Match a string of characters that start with
the beginning of a word and go to the end of the line
(?<=^\w+\s{3,}) The match above must be preceded by a word that starts
at the beginning of the line and must have a minimum
of 3 spaces after that word
There are lots of ways to approach but the above should work.
Alan
Alan Churchill
Savian "Bridging SAS and Microsoft Technologies"
www.savian.net
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Alan
Churchill
Sent: Tuesday, May 23, 2006 6:26 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: How to use Perl Regular expressions
Richard,
Here's an expression that matches. Make sure you do it multiline:
(?<=^\w+\s{3,})(\b.+$)
You can test it if you have something like RegexBuddy. Check the "match at
line breaks" if you decide to use that tool.
Alan
Alan Churchill
Savian "Bridging SAS and Microsoft Technologies"
www.savian.net
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Richard
Gong
Sent: Tuesday, May 23, 2006 5:43 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: How to use Perl Regular expressions
the following is the sample list. The goal is saving the models into a macro
variable.
From:
---------- List-----------
Cadillac Escalade EXT
Chevrolet Avalanche
Chevrolet Silverado 2500/3500
Dodge Ram 1500 (include Mega Cab)
Ford F-150
Ford F-250/350
To:
-----Nameplate----------- -----Model-------
Cadillac Escalade EXT
Chevrolet Avalanche
Chevrolet Silverado 2500
Chevrolet Silverado 3500
Dodge Ram 1500
Dodge Ram 1500 Mega Cab
Ford F-150
Ford F-250
Ford F-350
The value of macro variable is:
'Escalade EXT' ,' Avalanche', 'Silverado 2500','Silverado 3500','Ram
1500','Ram 1500 Mega Cab','F-150','F-250','F-350'