Another regex problem - help!

From: Date: Sat, 16 Oct 2004 19:54:53 +0000
Subject: Another regex problem - help!
Groups: php.general 
Request: Send a blank email to php-general+get-199640@lists.php.net to get a copy of this message
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

« previous php.general (#199640) next »