extracting a pattern using RE
Peoter Veliki
peoter_veliki at hotmail.com
Thu Nov 29 20:02:11 EST 2001
In perl you can use variables within regular expressions to extract patterns, something like this:
string ~= /\((.*)\)/g
pattern = $1
Probably not correct, but it is attempting to extract text surrounded by parenthes
if string equals '(hello)', pattern would equal 'hello'. How can this be done in Python?
I also am having problems with recursive patterns, what if I want to do the same thing with string = '(hello (there))' , I want to be able to extract both 'hello (there)' and 'there'.
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20011129/c097432c/attachment.html>
More information about the Python-list
mailing list