Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   PHP (http://www.programmingforums.org/forum29.html)
-   -   RegEx problem.. (http://www.programmingforums.org/showthread.php?t=12435)

cyphix Jan 24th, 2007 5:44 PM

RegEx problem..
 
Could anyone tell me why this regex pattern..

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

..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..

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

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?

Thanks!

dr.p Jan 25th, 2007 6:51 AM

[ ] indicates a character class. Only individual characters go in there, not characters grouped with ( ).

cyphix Jan 25th, 2007 7:02 AM

So anything I can do to achieve what I want to do?

Arevos Jan 25th, 2007 7:05 AM

It seems to be as if the best way to debug the regular expression is to remove successively greater parts of it until it works, and thus identify the part of the regular expression that is failing to match.

Styx Mar 4th, 2007 6:24 AM

You'd either have to take out that (<b>) part towards the end or put it somewhere around there as (^<b>)


All times are GMT -5. The time now is 3:06 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC