Date: Tue, 15 Mar 2005 17:12:45 -0500
Reply-To: "Chang Y. Chung" <chang_y_chung@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Chang Y. Chung" <chang_y_chung@HOTMAIL.COM>
Subject: Re: What is the regular expression for SAS format name?
On Tue, 15 Mar 2005 16:24:55 -0500, Richard A. DeVenezia
<radevenz@IX.NETCOM.COM> wrote:
>Chang:
>
>I think your pattern is missing some endpoint conditions, specifically one
>character format names.
>The following is more robust, but for the sake of me, I could not get the \1
>backticking to perform as I supposed it would. (e.g. when I replace a later
>([A-Za-z_]) with \1 to resuse the first subpattern, the matches dont come
>out as expected)
Hi, Richard,
You are absolutely correct. My pattern is still not correct. Yours is. I
could not make the back referencing work, either. Hmmmm... :-(
I was able to factor out the beginning and ending of the string. I am using
a non-capturing parens here, but regular parens work also.
pattern= '/^(?:'
|| '[A-Za-z_]'
|| '|' || '[A-Za-z_]\w{0,30}[A-Za-z_]'
|| '|' || '\$[A-Za-z_]'
|| '|' || '\$[A-Za-z_]\w{0,29}[A-Za-z_]'
|| ')\s*$/'
;
Cheers,
Chang
|