Question about a regular expression
Rob Hodges
s323140 at student.uq.edu.au
Tue Dec 21 12:12:53 EST 1999
Yoav I H Parish <parish at ikb.mavt.ethz.ch> writes:
> Hello,
>
> i have a string which could look something like
>
> a(x,y)b(x)
> or
> c(x,y,z)b(x)a(x,y)
>
> I would like to extract the parameters within the parantheses.
> The values ought to be separated. What kind of regular expression
> for re.split could I use? I have tried several, but can't seem to get it
> right...
I'd use a regexp (.*?) to grab the entire contents of each paren pair,
and then extract the parameters from there with string.split.
IMO, once regexps become too difficult to formulate, you are better
off taking a different approach if you can.
-Rob
More information about the Python-list
mailing list