Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8

Thread: RegEx problem..

  1. #1
    Regular Coder
    Join Date
    Apr 2004
    Posts
    682
    Thanks
    24
    Thanked 1 Time in 1 Post

    RegEx problem..

    Could anyone tell me why this regex pattern..

    PHP Code:
    <a href="http://www\.test\.com/lyrics/[^/]+/[^/]+/[^\.]+\.html" title="[^"]+"[^>]*>[^(<b>)\<]+</a> 
    ..isn't matching this line?

    Code:
    <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 Code:
    if (preg_match('~<a href="http://www\.test\.com/lyrics/[^/]+/[^/]+/[^\.]+\.html" title="[^"]+"[^>]*>[^(<b>)\<]+</a>~'$line)) { 
    Thanks!

  • #2
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Because of the b in "[^(<b>)\<]"
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.

  • #3
    Regular Coder
    Join Date
    Apr 2004
    Posts
    682
    Thanks
    24
    Thanked 1 Time in 1 Post
    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?

  • #4
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Not in character classes. <b> won't match as you already have < in that class.
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.

  • #5
    Regular Coder
    Join Date
    Apr 2004
    Posts
    682
    Thanks
    24
    Thanked 1 Time in 1 Post
    So how do I go about achieving what I need to do?

  • #6
    Regular Coder
    Join Date
    Apr 2004
    Posts
    682
    Thanks
    24
    Thanked 1 Time in 1 Post
    Anybody?

  • #7
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    ... Just remove the "(<b>)\". I've alraytdy told you that <b> won't match because the "<" can't be matched.
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.

  • #8
    Regular Coder
    Join Date
    Apr 2004
    Posts
    682
    Thanks
    24
    Thanked 1 Time in 1 Post
    So I can't search for entries that don't contain "<b>" then?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •