Re: regular expression

From: Date: Fri, 02 Jul 2004 19:36:20 +0000
Subject: Re: regular expression
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-189577@lists.php.net to get a copy of this message
First of all, you might want to put more than one %.... probably like %%% Reason is, asp users <% %> like php uses <? ?>. Just a precaution. You almost had the regex right. /%[a-z]+%/i Thans means, starts with a %, can match a-z, at least once (the + part) but as many times (greedy), then another %, and the i means case-insensitive. If you don't have that you'd have to do [a-zA-Z] instead. Also, will there be anything else in there besides just alpha chars? -Josh On Fri, 2 Jul 2004 13:56:29 -0500, George Lantz <glantz@mostlymemories.com> wrote: > > Could someone help me with a regular expression? I am not very good at > them. I want to find the following pattern inside a file: > > [%string%] > > Then extract the string portion to store in array. I would next like to > replace those patterns with html code. That's right you guessed it a > template engine type program. > > I thought it was"/\[\%[a-z]\%\]" but I guess I am wrong. Then what > function do I use to extract. > > Thank you, > George >

« previous php.general (#189577) next »