Results 1 to 2 of 2

Thread: Perl: Strip URLs from text ?

  1. #1

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Perl: Strip URLs from text ?

    I'm very new to perl, and I need to strip out URLs from a piece of text.
    So, the text might be for example :

    Code:
    This is <a href="something.blah?dfoj_sdjf=something">a test</a> blah!
    And I would need it to simply say "This is a test".
    I'd have no problem doing this in VB, but christ, in perl I've not a clue really....
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Let's say your string is string 1.

    string1 = "This is <a href="something.blah?dfoj_sdjf=something">a test</a> blah!"



    POSN1 = index(string1,"<a") will return the position of "<a href"

    POSN2 = index(string1,">",POSN1) will return the position of it's closing tag.

    then use

    substr (string1,POSN1,POSN2-POSN1,"")

    and you should get the string without the hyperlink.

    Then run it again for the </a> tag.

Posting Permissions

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



Click Here to Expand Forum to Full Width