By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,748 Members | 1,300 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,748 IT Pros & Developers. It's quick & easy.

Re: Module re, extract on string match

P: n/a
On Mon, Aug 4, 2008 at 4:54 PM, Sriram Rajan <sr*********@acm.orgwrote:
I am wondering if I can use re.search to extract from a particular
location in a string.
Example:
string1='/Users/sriram/folder1/folder2/folder3/folder4/folder5/file'
re.search ('folder3,string1)

<Extract /folder3/folder4/folder5/file>

Thanks,

Sriram
Something like below?

Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:16)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>import re
s = '/Users/sriram/folder1/folder2/folder3/folder4/folder5/file'
y = re.search('folder3.*', s)
y.group()
'folder3/folder4/folder5/file'
>>>

--
Stand Fast,
tjg. [Timothy Grant]
Aug 5 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.