Not quite as I wanted it, it should fail when running the second alternative as below:
$sString = '<a href="#" onclick="asdjh"><img src="{$test}"></a>';
echo $sString . "\n";
if (preg_match('/<a(.?){\$test}(.?)<\/a>/', $sString))
{
echo "found\n";
}
else
{
echo "not found\n";
}
$sString = '<a href="#" onclick="asdjh">asdf</a><img src="{$test}"><a href="#" onclick="asdjh">asdf</a>';
echo $sString . "\n";
if (preg_match('/<a(.?){\$test}(.?)<\/a>/', $sString))
{
echo "found\n";
}
else
{
echo "not found\n";
}
It must fail when it finds a </a> or </A> between <a and {$test}
Thank you anyway! 🙂
Andreas
vincent wrote:
try this:
Note the SINGLE QUOTES around the pattern!
$sString = '<a href="#" onclick="asdjh"><img src="{$test}"></a>';
if (preg_match('/<a(.?){\$test}(.?)<\/a>/', $sString))
{
echo 'found';
}
else
{
echo 'not found';
}
$sString = '<a href="#" onclick="asdjh">asdf</a><img src="{$test}">';
if (preg_match('/<a(.?){\$test}(.?)<\/a>/', $sString))
{
echo 'found';
}
else
{
echo 'not found';
}