regular expression for reading a template

liunx

Guest
I need to write a regular expression for the following format:
(3 parameters)
{{call module = "Your Account","account_information.html","sidebar/"}}
{{call module = "Quick Search","search_quicksearch.html","sidebar/"}}
{{call module = "Random Product","product_random.html","sidebar/"}}
{{call module = "Site Information","document_list.html","sidebar/"}}

or (4 parameters)

{{call module = "Your Account","account_information.html","sidebar/","shopping_cart.html"}}

So far I have tried:
preg_match("/(\\{\\{call module \\= \"[\\w:space:]\",\"[\\w:space:]\",\"[\\w:space:]\"\\}\\})/isu",$contents)
preg_match("/(\{\{call module \= \"([\w:space:]+)\",\"([\w:space:]+)\",\"([\w:space:]+)\"\}\})/isu",$contents)

This is not working and I have tried various renditions, but all have failed. I wish I had a firm understanding of regular expressions but I have yet to find a nice tutorial that I understood entirely.

Could anyone help me out?
-MattHey Matt :)

I have one question? why?

what would that point be to use a regular expression on that?

what are you trying to match? or are you just trying to get the these

Your Account","account_information.html","sidebar/

into a variable?

just right off the top of my head

preg_match("/(\{\{call module \= ["]\s["],["]\s["],["]\s["]\}\})/U",$contents)

but, I think you have to escape the comma's, not sure, been awhile.

let me know what you are trying to do exactly and I will play around with it. I don't have much time today but I will look into it and let you know.The reason behind it is to eventually place what is in quotes as parameters of a function for my cpCommerce script.

I have been rewriting the whole template system and the above is used in the new template style.

-Mattwell I was close, just had teh wrong \s in there.


<?
$text="{{call module = \"Your Account\",\"account_information.html\",\"sidebar/\"}}";
$ptn = '/(\S+)\s(\S+)\s(\S+)\s[\"](.+)[\"],[\"](.+)[\"],[\"](.+)[\"]/';
if(preg_match($ptn,$text, $match)){
echo "found something = ". $match[4]."<br />";
}else{
echo "didn't find anything";
}

?>wohoo! thanks a ton.

-Matt
 
Back
Top