Try
"/<!--begin variable:?([\w\s]*?)-->([\w\s]*?)/m"

the "?" will force PCRE to not be *greedy*. Look in the manual of PCRE for
syntaxis.

Andrey Hristov
IcyGEN Corporation
http://www.icygen.com
99%
----- Original Message -----
From: "Sondra Russell" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 23, 2001 5:32 PM
Subject: [PHP] Grep Challenge 2001


> Hello everyone!
>
> Here's my grep challenge. Turn:
>
> <!--begin variable: variable_blah-->
> blah blah
> blah blah
> blah blah
> blah blah
>
> <!--begin variable: variable_blah2-->
> blah 2 blah 2
> blah 2 blah 2
> blah 2 blah 2
> blah 2 blah 2
>
> into:
> (variable_blah) (blah blah blah blah blah blah blah blah)
> (variable_blah2) (blah 2 blah 2 blah 2 blah 2 blah 2 blah 2 blah 2 )
>
> Where the "blahs" (that are not part of the variable name) contain
> practically anything but the next comment "<!--begin variable:".
> Also the "blahs" maintain their \n and such (I just flattened those
> values out for demo purposes here).
>
> I've tried:"/<!--begin variable:?([\w\s]*)-->([\w\s]*)/m", but that
> misses out on any punctuation and "/<!--begin
> variable:?([\w\s]*)-->(.*)/m" gives me some other weirdness-- it
> doesn't find anything at all for the second substring.
>
> Any suggestions!
>
> Thanks cowboys!
> Sondra
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to