Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 24th, 2007, 5:44 PM   #1
cyphix
Newbie
 
Join Date: Jan 2007
Posts: 2
Rep Power: 0 cyphix is on a distinguished road
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!
cyphix is offline   Reply With Quote
Old Jan 25th, 2007, 6:51 AM   #2
dr.p
Programmer
 
dr.p's Avatar
 
Join Date: Feb 2006
Location: Ohio
Posts: 93
Rep Power: 3 dr.p is on a distinguished road
[ ] indicates a character class. Only individual characters go in there, not characters grouped with ( ).
__________________
Neeley.org
dr.p is offline   Reply With Quote
Old Jan 25th, 2007, 7:02 AM   #3
cyphix
Newbie
 
Join Date: Jan 2007
Posts: 2
Rep Power: 0 cyphix is on a distinguished road
So anything I can do to achieve what I want to do?
cyphix is offline   Reply With Quote
Old Jan 25th, 2007, 7:05 AM   #4
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4 Arevos is on a distinguished road
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.
Arevos is offline   Reply With Quote
Old Mar 4th, 2007, 6:24 AM   #5
Styx
Programmer
 
Join Date: Mar 2007
Posts: 39
Rep Power: 0 Styx is on a distinguished road
You'd either have to take out that (<b>) part towards the end or put it somewhere around there as (^<b>)
Styx is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:44 AM.

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