|
-
Sep 21st, 2003, 09:22 AM
#1
Thread Starter
Retired VBF Adm1nistrator
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]
-
Sep 21st, 2003, 06:49 PM
#2
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|