![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jan 2007
Posts: 2
Rep Power: 0
![]() |
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! |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Feb 2006
Location: Ohio
Posts: 93
Rep Power: 3
![]() |
[ ] indicates a character class. Only individual characters go in there, not characters grouped with ( ).
__________________
Neeley.org |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Jan 2007
Posts: 2
Rep Power: 0
![]() |
So anything I can do to achieve what I want to do?
|
|
|
|
|
|
#4 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4
![]() |
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.
|
|
|
|
|
|
#5 |
|
Programmer
Join Date: Mar 2007
Posts: 39
Rep Power: 0
![]() |
You'd either have to take out that (<b>) part towards the end or put it somewhere around there as (^<b>)
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Stuck with a C problem | Polaris | C++ | 8 | Aug 19th, 2006 3:30 PM |
| Huge arrays in C (game-oriented problem theme) | Rather Generic | C | 6 | Mar 19th, 2006 1:09 AM |
| cgi/perl script + IE problem | joyceshee | Perl | 2 | Jan 24th, 2006 11:10 AM |
| help with recursion problem | the_new_guy_in_town | Java | 3 | Apr 7th, 2005 3:04 AM |