...

View Full Version : RegEx problem..



cyphix
01-23-2007, 10:09 PM
Could anyone tell me why this regex pattern..



<a href="http://www\.test\.com/lyrics/[^/]+/[^/]+/[^\.]+\.html" title="[^"]+"[^>]*>[^(<b>)\<]+</a>


..isn't matching this line?



<a href="http://www.test.com/lyrics/a_lyrics_4179/lyrics_12737/everybody_in_lyrics_148006.html" title="Everybody In lyrics">Everybody In</a><br>


This is my code..



if (preg_match('~<a href="http://www\.test\.com/lyrics/[^/]+/[^/]+/[^\.]+\.html" title="[^"]+"[^>]*>[^(<b>)\<]+</a>~', $line)) {


Thanks!

marek_mar
01-23-2007, 10:30 PM
Because of the b in "[^(<b>)\<]"

cyphix
01-23-2007, 10:54 PM
But I don't want lines with "<b>" included..... isn't that the right way to do it? By enclosing a series of characters in parentheses?

marek_mar
01-24-2007, 09:02 AM
Not in character classes. <b> won't match as you already have < in that class.

cyphix
01-24-2007, 11:36 AM
So how do I go about achieving what I need to do? :confused:

cyphix
01-24-2007, 10:33 PM
Anybody? :confused:

marek_mar
01-25-2007, 12:03 AM
... Just remove the "(<b>)\". I've alraytdy told you that <b> won't match because the "<" can't be matched.

cyphix
01-25-2007, 12:05 AM
So I can't search for entries that don't contain "<b>" then?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum