1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[Help] using regex

Discussion in 'General Scripting Chat' started by bzy39, Sep 24, 2009.

  1. bzy39

    bzy39 Regular Member

    Joined:
    Jan 15, 2009
    Messages:
    434
    Likes Received:
    239
    help me to rename or to remove google news url in this regex

    HTML:
    http://news.google.com/news/url?fd=R&sa=T&url=http://www.presstv.ir/detail.aspx?id=106989&sectionid=351020104&usg=AFQjCNGBRlMb3AeBvxb24vx46rvbe9EgzA
    to

    HTML:
    http://www.presstv.ir/detail.aspx?id=106989
    i have try using this regex

    \b(https?)://[-A-Z&@#/%?=~_|!:,.;]*(url)=

    but it only remove

    HTML:
    http://news.google.com/news/url?fd=R&sa=T&url=
    i'm new in regex :rolleyes:

    thank
     
  2. dukefx

    dukefx Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 8, 2009
    Messages:
    246
    Likes Received:
    109
    Occupation:
    VP Information Technology
    Location:
    Dagobah
    I threw together a quick regex that does the job

    pattern:
    /^.*\&url=((http://)*(https://)*(www\.)*([A-z])+\.([A-z]{2,4})+(\/[A-z,0-9]+\.)([^\&])*).*/

    replace with
    $1
     
    • Thanks Thanks x 1
  3. BozoClown

    BozoClown Junior Member

    Joined:
    Jan 4, 2009
    Messages:
    150
    Likes Received:
    106
    A quickie
    Code:
    h.+url=
     
    • Thanks Thanks x 1
  4. parse

    parse Registered Member

    Joined:
    Mar 14, 2009
    Messages:
    67
    Likes Received:
    23
    This is better:

    Code:
    /url=(.*)/
     
    • Thanks Thanks x 1
  5. bzy39

    bzy39 Regular Member

    Joined:
    Jan 15, 2009
    Messages:
    434
    Likes Received:
    239
    thank all, i will try it