Extracting multine string
Posted: Tue Dec 19, 2006 5:40 am
I have a very simple reg ex function which matches a custom tag as follows :
<#if:var1:eq:var2>
var1 can be any string, and in many instances can be a multi line string, causing the rest of the tag too movie down :
I have created a reg ex function to extract these tags from a file and works perfectly for thosae instance where var1 is NOT multi line :
This returns the whole tag, but fails when var1 (.*?) spans across multipple lines. Addeding the /s and /m modifiers has no effect!
It does however return everything upto the first newline \n eg, some sample output :
After the word Sulphate it stops as it has encountered a newline character, is there anyway too make it retreive everything including newline characters? and therefore return the rest of match, without having to manually replace newline characters?
Tried allsorts with this so any help would be great!
<#if:var1:eq:var2>
var1 can be any string, and in many instances can be a multi line string, causing the rest of the tag too movie down :
I have created a reg ex function to extract these tags from a file and works perfectly for thosae instance where var1 is NOT multi line :
Code: Select all
preg_match_all("/<\#if:.*?>/s", $Template, $StartTags, PREG_OFFSET_CAPTURE);It does however return everything upto the first newline \n eg, some sample output :
Code: Select all
Array
(
[0] => Array
(
[0] => Array
(
[0] => <#if:600mg Glucosamine Sulphate
[1] => 1624
)
)
)Tried allsorts with this so any help would be great!