kj wrote:
In <h5cotl$or...@reader1.panix.com> kj <no.em...@please.post> writes:



One of the nice things one can do with Perl's regexp's is illustrated
in the following example:

my $gly = qr/gg[ucag]/i
my $ala = qr/gc[ucag]/i;
my $val = qr/gu[ucag]/i;
my $leu = qr/uu[ag]|cu[ucag]/i;
my $ile = qr/au[uca]/i;

my $aliphatic = qr/$gly|$ala|$val|$leu|$ile/;


In other words, one can build regular expressions by re-combining
other regular expressions.

Is there a way to do this with Python's regexps?


OK, answering my own question here, it looks like the only way to
do this is to leave the "component" expressions as regular strings,
and combine those, before compiling them into regexps.

Easy enough.

A compiled regular expression has 'pattern' and 'flags' attributes, so
you can get the original parameters which were used to create it if a
function is given just the compiled regular expression. Might be useful.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to