Re: [PHP] Another regex problem - help!

2004-10-16 Thread Jason Wong
On Sunday 17 October 2004 03:54, Murray @ PlanetThoughtful wrote:

 In this case, I'm trying to perform a preg_match using the following
 expression:

 preg_match(/^\[\[ft.$fn[1].:(.*)\]\]$/m,$content,$ft);

Nearly there, except that ']' is not a special char and should not be escaped. 

 In the above example, the preg_match would be applied twice, once with a
 $fn[1] value of 1, the second time with a $fn[1] value of 2. The $content
 variable contains the string above.

Not sure why you would want to apply the regex more than once. You use:

  preg_match_all('/^\[\[ft\d{1}:(.*)]]$/m', $content, $ft)

That will match ft0 upto ft9, season to taste.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Life is difficult because it is non-linear.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Another regex problem - help!

2004-10-16 Thread Murray @ PlanetThoughtful
Hi All,

I'm trying to match a particular pattern in a multi-line string. The string
might look like:

string

Some text.

Some more text.

[[ft1: An example of the search string [[fn2

[[ft2: Another example of a search string]]

Extra text

/string

In this case, I'm trying to perform a preg_match using the following
expression:

preg_match(/^\[\[ft.$fn[1].:(.*)\]\]$/m,$content,$ft);

In the above example, the preg_match would be applied twice, once with a
$fn[1] value of 1, the second time with a $fn[1] value of 2. The $content
variable contains the string above.

I'm attempting to accommodate a situation where the target string might
contain ]] before I want the capture to finish, as in the first example
above. I'm hoping to return both the whole value matched by the preg_match,
as well as the content of the matched string after the : character up to
the final closing ]] for the line.

In essence, the closing ]] for the match should always be at the end of
the line.

My attempt to build a pattern, as above, isn't working. I'm wondering if
anyone can give me some advice on how to fix it?

Many thanks in advance and much warmth,

Murray

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php