I have some strings like '/home/dir/file1/file2' , '/export/home/file1'
'/home/dir1/dir2/folder1/file'

I want to only to print the values that come after first two occurences of '/' like for first string '/home/dir/file1/file2' I want to print 'dir/file1/file2'

How to do this

Thanks

Recommended Answers

All 2 Replies

Here!

s = '/home/dir1/dir2/folder1/file' 
list_s = s.split('/')
print '/'.join(list_s[1:]

Thanks, that worked great.

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.