Page 1 of 1

Preg_Match?

Posted: Wed Sep 15, 2004 9:02 pm
by Mr Tech
Hey there!

I'm using the preg_match() function to retreieve information from a file. This is an example of the file:

Code: Select all

<?php
$title = <<<EOF
Title goes here
EOF;
$body = <<<EOF
Content goes here
EOF;
?>
Now when I use this query:

Code: Select all

<?php
if( preg_match( "/title = <<<EOF([^\|]*)EOF;/is", $content, $match ) )
$title = $match[1];
?>
It get the content from the $title all the way down to the end of the $body tag when I only want the $title. I tried ([^\EOF;]*) but it didn't work...

Any suggestions?

Posted: Wed Sep 15, 2004 11:14 pm
by feyd

Code: Select all

(&#1111;^\|]*?)

Posted: Wed Sep 15, 2004 11:34 pm
by Mr Tech
Awesome works well! Also, it it possible to remove this part: [^\|] so it's like (*?) I tried it but it didn't work because I don't want it to not work if there is a | in the text...

Thanks again!

Posted: Wed Sep 15, 2004 11:39 pm
by feyd

Posted: Wed Sep 15, 2004 11:46 pm
by Mr Tech
Thanks, will do.