Preg_match help needed.

SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
Watch

bliss

VIP Member
Impact
15
PHP:
    $match_expression = '<br><span class\=a>(.*)\/<\/span><\/font>';
    preg_match($match_expression,$total,$matches); 
    return strip_tags($matches[1]);
Warning: preg_match() [function.preg-match]: Unknown modifier '<' in /home/website/public_html/directory/myscript.php on line 21
Is giving me an error. Why? I did not think you had to escape < and > operators.


-
 
Last edited:
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Try this:

PHP:
$match_expression = '/<br><span class\=a>(.*)/<\/span><\/font>/'; 
    preg_match($match_expression,$total,$matches);  
    return strip_tags($matches[1]);
 
0
Close
Found it. What you had was close thanks!

PHP:
$match_expression = '/<br><span class\=a>(.*)\/<\/span><\/font>/i';
preg_match($match_expression,$total,$matches); 
return strip_tags($matches[1])
 
0
Close
Remember that you have to escape the characters ^.[$()|*+?{\ (if you want to 'match' the character and not use their function) with a backslash everytime :).
 
0
Close
Dismounted: No, what was I missing was not one of those. It was the escape on the / and the /i at the very end, but yes that is always great to know.
 
Last edited:
0
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Filters for activity feeds
Your news feed, Latest activity, and the activity tab on profiles now have filter buttons: All, Posts, Quick replies, and Other. Your...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back