...

View Full Version : Finding value between two words



kjc777
07-29-2008, 04:23 AM
Hi,

I am trying to find the text between 2 words.

The text I am looking at is partly:

#header{
background-image:url(/stylesheets/images/t1header.jpg);
height:120px
}
#headerText{


I have got:
preg_match("(header{(/?[^\>]+)#headerText)",$cssSource,$matches);
//cssSource is the above style code

This also returns the header{ and #headerText in matches. How can I get it to return just the text in between and not the two searched words.

At the moment the above code returns:
header{ background-image:url(/stylesheets/images/t100-1header.jpg); height:120px } #headerText

But i just want:
background-image:url(/stylesheets/images/t100-1header.jpg); height:120px

Thanks for any help

K

Apothem
07-29-2008, 05:58 AM
I'm not entirely sure if this will help, but:

$string = <<<A
#header{
background-image:url(/stylesheets/images/t1header.jpg);
height:120px
}
#headerText{
A;

preg_match("#background(.*)#", $string, $var, PREG_OFFSET_CAPTURE);
print_r($var);

Was able to give me something alike.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum