[SOLVED] Making preg_match() look through whole string
Posted: Sun May 07, 2006 12:04 pm
This is my preg_match() sequence:
In short, people submit a string that can have multiple sections of source code:
Assuming that someone submitted that, I want preg_match() to recognize the <php> section and <java> section.
Currently it will only recognize the php section though. Is there a way I can make it traverse through $str until the last occurrance instead of it only matching one regex?
Code: Select all
preg_match("/<([a-z]*)?\>(.*?)\<\/([a-z]*)?\>/s", $str, $matches);Code: Select all
Hello World in php:
<php>
<?php
echo "Hello World";
?>
</php>
And in java:
<java>
System.out.println("Hello World");
</java>
That's basically itCurrently it will only recognize the php section though. Is there a way I can make it traverse through $str until the last occurrance instead of it only matching one regex?