Ahlahn
05-29-2011, 05:24 PM
Hey guys,
I'm trying to get this regex match to output an array with all the characters that were successfully matched, but it's excluding the <h1></h1> characters since those are interpreted as HTML. I know htmlentities could be useful, but I'm not sure how I would implemented within this script ->
$regexMatch = preg_match_all($expression, $string, $matches,PREG_OFFSET_CAPTURE);
if($array > 0){
echo "Sucess";
echo "<pre>";
print_r($matches);
echo "</pre>";
}
else
echo "No Match";
$matches represents the array containing the matched items- how do I get it to display meta-characters as well?
Here are the outputs
Expression = "/Hello/"
String = "Hello"
(
[0] => Array
(
[0] => Array
(
[0] => Hello
[1] => 0
)
)
)
but....
$expression = "/\<h1\>hello\<\/h1\>/"
$string = "<h1>hello</h1>"
Array
(
[0] => Array
(
[0] => Array
(
[0] =>
Hello]
[1] => 0
)
)
)
I'm trying to get this regex match to output an array with all the characters that were successfully matched, but it's excluding the <h1></h1> characters since those are interpreted as HTML. I know htmlentities could be useful, but I'm not sure how I would implemented within this script ->
$regexMatch = preg_match_all($expression, $string, $matches,PREG_OFFSET_CAPTURE);
if($array > 0){
echo "Sucess";
echo "<pre>";
print_r($matches);
echo "</pre>";
}
else
echo "No Match";
$matches represents the array containing the matched items- how do I get it to display meta-characters as well?
Here are the outputs
Expression = "/Hello/"
String = "Hello"
(
[0] => Array
(
[0] => Array
(
[0] => Hello
[1] => 0
)
)
)
but....
$expression = "/\<h1\>hello\<\/h1\>/"
$string = "<h1>hello</h1>"
Array
(
[0] => Array
(
[0] => Array
(
[0] =>
Hello]
[1] => 0
)
)
)