Quick Pregmatch help needs :)

Discussion in 'PHP' started by ruby90, Jun 24, 2008.

  1. #1
    Hey I want help to extract from this code

    <td width=165 valign=top style='padding-bottom:2px;'>
    <a class=s target=_blank href='http://www.example.com/42432423'>Example Text</a></td>
    <td width=35></td>
    
    Code (markup):
    Want to extract

    code : 42432423
    text : Example Text

    that's all much appreciate your help.

    thanks :)
     
    ruby90, Jun 24, 2008 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    Im not very good in regex but here's a try

    '!http:\/\/www.example.com/([0-9])+\'>\[a-zA-z-0-9 ]\<\/a\>!ism';

    Try this ;)
     
    EricBruggema, Jun 25, 2008 IP
    ruby90 likes this.
  3. Demonic

    Demonic Active Member

    Messages:
    821
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    85
    #3
    wrong... @ eric

    @\<a href='http://www\.example\.com/(\d+)/'\>[a-zA-Z0-9-_]+\</a\>@ism
    Code (markup):
     
    Demonic, Jun 25, 2008 IP
    ruby90 likes this.
  4. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #4
    @Demonic; i told the ts already that i suck at this, but what the hell, just giving it a try! your example is indeed very much better than mine ;) (got to learn from it).

    B.t.w wheres the part in [a-zA-Z0-9-_] wich allows a space?
     
    EricBruggema, Jun 25, 2008 IP
  5. Demonic

    Demonic Active Member

    Messages:
    821
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    85
    #5
    I updated him via pm:

    @\<a[^>]+href=\'http\:\/\/www\.redtube\.com\/(\d+)\'>([a-zA-Z0-9-_ ]+)\<\/a\>@isU
    Code (markup):
    Btw you didn't escape the "." periods, that means MATCH ALL in the regular expression syntax ;).
     
    Demonic, Jun 25, 2008 IP
  6. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #6
    :D well i've learnd from my mistakes :)
     
    EricBruggema, Jun 25, 2008 IP
  7. ruby90

    ruby90 Peon

    Messages:
    721
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks every one I got that worked :) All repped :p
     
    ruby90, Jun 25, 2008 IP