No, actually i was wrong about this subject. The correct Regular Expression
for this is the following:
preg_match_all("/(<\?.*?\?>)/ims",$text,$source_code);
The anterior was greedy, and so it matched the following:
And now it only takes the text between , even multilined code.
--
PHP Gene
¡¡¡ Got it !!
It even matches the linebreaks, so it can color multi-line code. Look at
this sample:
- TEXT TO USE FOR SEARCHING
PATTERNS --
-- END
TEXT ---
Scri
iskuuta 2003 14:59
To: [EMAIL PROTECTED]
Subject: [PHP] Help with ereg()
Hi all. I'm trying to deal with Regular Expressions, but somehow it is
getting more difficult. I´m trying to do the folowing:
Read a text and get all of the PHP code out of it, highlight it and then
print all in nice HTML.
Hi all. I'm trying to deal with Regular Expressions, but somehow it is
getting more difficult. I´m trying to do the folowing:
Read a text and get all of the PHP code out of it, highlight it and then
print all in nice HTML. I'm using this to get the PHP code:
ereg("<\?.*\?>",$Text,$PHP_code);
It
4 matches
Mail list logo