A nie prościej potraktować taki tekst
strip_tags?
Jak już koniecznie chcesz znaleźć ten href, to jest na to bardzo wiele sposobów:
http://www.php.net/strpos<?php
$str = '<a href="http://example.com">example</a>';
$find = 'href';
{
// znaleziony
} else
{
// nie znaleziony
}
http://www.php.net/strstr<?php
$str = '<a href="http://example.com">example</a>';
$find = 'href';
{
// znaleziony
} else
{
// nie znaleziony
}
http://www.php.net/strpbrk<?php
$str = '<a href="http://example.com">example</a>';
$find = 'href';
if(strpbrk($str, $find))
{
// znaleziony
} else
{
// nie znaleziony
}
http://www.php.net/strrchr<?php
$str = '<a href="http://example.com">example</a>';
$find = 'href';
{
// znaleziony
} else
{
// nie znaleziony
}
http://www.php.net/preg_match<?php
$str = '<a href="http://example.com">example</a>';
$find = 'href';
{
// znaleziony
} else
{
// nie znaleziony
}
I pewnie jeszcze kilka sposobów na znalezienie podciągu w ciągu by się znalazło. Te tak na szybko, co mi przyszły do głowy.
Zamiast wyrażenia regularnego (preg_match) zalecam użycie strpos, lub innej funkcji, w zależności od dalszych potrzeb.