matching a string to extract substrings for which some function returns true

Amit Khemka khemkaamit at gmail.com
Tue Nov 22 12:27:41 CET 2005


Hello All,

say you have some string: "['a', 'b', 1], foobar ['d', 4, ('a', 'e')]"
Now i want to extract all substrings for which
"isinstance(eval(substr), list)" is "True" .
now one way is to walk through the whole sample string and check the
condition, I
was wondering if there is any smarter way of doing the same, may be
using regular-expressions.

Thanks,
amit.

----
Endless the world's turn, endless the sun's spinning
Endless the quest;
I turn again, back to my own beginning,
And here, find rest.



More information about the Python-list mailing list