Module re, extract on string match
Timothy Grant
timothy.grant at gmail.com
Mon Aug 4 20:28:52 EDT 2008
On Mon, Aug 4, 2008 at 4:54 PM, Sriram Rajan <sriramrajan at acm.org> wrote:
> 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]
More information about the Python-list
mailing list