Re: A small problem
| From: | Chris Hayes | Date: | Tue, 11 Mar 2003 13:06:02 +0000 |
| Subject: | Re: A small problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-139127@lists.php.net to get a copy of this message | ||
At 13:56 11-3-03, you wrote:
Can you pick a decent subject like "help with regular expressions" rather than something pointless and generic like "a small problem"... a lot of readers will skip over generic subject lines, and you also miss out on attracting the attention of those who regexps well. a good suggestion.however i saw it anyway, i would suggest to try this: <?PHP
$Text="<? echo \"aaaa\"; ?> This is some other no php code <? echo \"this is PHP\";?>";preg_match_all("|<[^>]+>|",$Text,$PHP_code); //Note that preg_match_all puts the matches in array $PHP_code[0].
//outputfor ($i=0;$i<count($PHP_code[0]);$i++)
{ echo "<br>$i:".htmlspecialchars($PHP_code[0][$i]);
}
?>
Oh and regular expressions are more clever than you would think, it's just that they can do so much more than you think.