hi..
can anybody help me to have more efficient code..
i tried to do some simple regex to split an URL
i tried to do this on my own many times but i couldnt seem to get it right
i havent master regex yet..(im learning - but the learning curve is not as fast as i expected to)

site=re.split('/+','http://mercury.tiser.com.au/IMPCNT/ccid=26434/acc_random=57289995/SITE=NEWS/AREA=NEWS.HOME/NETWORKPROMO=SPOTLIGHT/AAMSZ=210X160/pageid=62961499')
print site

it will breaks up the url in to small chunks of list items everytime it encounter '/'

and i also tried

y=re.split(':/{1,2}','http://www.mercury.tiser.com.au/blabla')
print y

and it will give me


but what i really want is to make it look like

when the input is

http://mercury.tiser.com.au/IMPCNT/ccid=26434/acc_random=57289995/SITE=NEWS/AREA=NEWS.HOME/NETWORKPROMO=SPOTLIGHT/AAMSZ=210X160/pageid=62961499

so i want to omit all the URL after .au/ and save it in the list

anybody knows how to make it look the way i need it?

thanks...

Recommended Answers

All 2 Replies

thanks heapss..that was really helpfull

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.