Jun 27, 2006 #1 danny2785 Programmer Joined Jun 26, 2006 Messages 16 Location US I am trying to grab the url without the protocol or the www. For example if you have http:http://www.google.com I just want google.com. I am currently using $line =~ /[^\n\r]+.(?=[\s\.,])/ Can anybody give me some suggestions? Thanks
I am trying to grab the url without the protocol or the www. For example if you have http:http://www.google.com I just want google.com. I am currently using $line =~ /[^\n\r]+.(?=[\s\.,])/ Can anybody give me some suggestions? Thanks
Jun 27, 2006 #2 brigmar Programmer Joined Mar 21, 2006 Messages 414 Location US If it is _only_ the protocol and "http://www." that you wish to strip: Code: while(<DATA>) { my ($field) = m#(?:[^:]://(?:[URL unfurl="true"]www\.)?)(.*)#;[/URL] print "[$field]\n"; } __DATA__ [URL unfurl="true"]http://www.google.com[/URL] [URL unfurl="true"]http://www.tek-tips.com/viewthread.cfm?qid=1247777&page=1[/URL] [URL unfurl="true"]http://www.perl.com[/URL] [URL unfurl="true"]http://perl.com/index.html[/URL] [URL unfurl="true"]http://somethingotherthanwww.perl.com[/URL] Upvote 0 Downvote
If it is _only_ the protocol and "http://www." that you wish to strip: Code: while(<DATA>) { my ($field) = m#(?:[^:]://(?:[URL unfurl="true"]www\.)?)(.*)#;[/URL] print "[$field]\n"; } __DATA__ [URL unfurl="true"]http://www.google.com[/URL] [URL unfurl="true"]http://www.tek-tips.com/viewthread.cfm?qid=1247777&page=1[/URL] [URL unfurl="true"]http://www.perl.com[/URL] [URL unfurl="true"]http://perl.com/index.html[/URL] [URL unfurl="true"]http://somethingotherthanwww.perl.com[/URL]