Thursday 3 December 2009

extract part of url

I want to extract strings after http:// and before querystring ? .This is how i did for the following url:


bash$echo "http://nwidget.networkedblogs.com/getnetworkwidgetmain?bid=224747&fancount=28"
\ | perl -ne 'print "input url : $_\n"; $_=~s#.*?.*//(.*?/.*?)\?.*#$1# and print "extract sting : $_\n";'

o/p:
input url : http://nwidget.networkedblogs.com/getnetworkwidgetmain?bid=224747&fancount=28
extracted string : nwidget.networkedblogs.com/getnetworkwidgetmain

No comments:

Post a Comment

Tweets by @sriramperumalla