[Tutor] string fomatting

bob gailer bgailer at gmail.com
Sat Jan 31 22:00:22 CET 2009


Jay Jesus Amorin wrote:
> Thanks bob.
>
> 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 /
>
> and when i print it will display *testmodule*.

Ah. Much clearer.

header = "https://www.localhost.org/"
test = "https://www.localhost.org/foo/bar" # we desire to extract 'foo'
start = len(header)
end = test[start:].find('/') + start
result = test[start: end]
print result

-- 
Bob Gailer
Chapel Hill NC
919-636-4239


More information about the Tutor mailing list