>> I want to search any characters in test after https://www.localhost.org/ >> <https://www.localhost.org/testmodule/dev/trunk/admin/sql/mytest.sql> and >> the search will end after it finds another /
here's another solution that takes advantage of the 'maxsplit' parameter of the str.split() method... it requires more stitching to get the final output(s): >>> url = 'https://www.localhost.org/testmodule/dev/trunk/admin/sql/mytest.sql' >>> parts = url.split('/', 4) >>> print '%s//%s/' % (parts[0], parts[2]) https://www.localhost.org/ >>> print parts[3] testmodule >>> print '/%s' % parts[4] /dev/trunk/admin/sql/mytest.sql -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Core Python Programming", Prentice Hall, (c)2007,2001 "Python Fundamentals", Prentice Hall, (c)2009 http://corepython.com wesley.j.chun :: wescpy-at-gmail.com python training and technical consulting cyberweb.consulting : silicon valley, ca http://cyberwebconsulting.com _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor