regex...same match within pattern<

liunx

Guest
hey all,

I'm working on a script where I need to use a lot of regex...but I've come to something I'm unfamilar with....how can I take a pattern such as:

:loop name="(.*)":(.*):end loop name="(.*)":

and make sure the first and last parts match up?

ie:

:loop name="(.*)":
(.*)
:end loop name="(.*)":


bold parts being the parts I want the same.I could loop through the place I'm getting the values from(a php array) but I'd rather leave it in the expression if possible.If there is a difference between ereg and pcre formats for this sort of operation,any pointers as to the equivilants would be appreciated.I was just thinking that maybe once you get the regular expression sorted out you can run it through a check. you can have a function in the preg_match or what ever you use.
so maybe something along the lines as this


preg_match("/loop name="(.*)":(.*):end loop name="(.*)", ".some_function(\\1, \\3).", $matches);

somefunction($one,$two){
//some if statement to check to see if they are the same.
}

that is just pulled off my head so it may need some tweaking.as we discussed on im...I got it working..I'm just implementing some tags now :D
 
Back
Top