-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Agreed. Two string.split()s, first at the semi-colon and then at the equal sign, will yield you your value, without having to fool around with regexes.
On 7/23/2009 9:23 AM, Mark Lawrence wrote: > scriptlear...@gmail.com wrote: >> For example, I have a string "#a=valuea;b=valueb;c=valuec;", and I >> will like to take out the values (valuea, valueb, and valuec). How do >> I do that in Python? The group method will only return the matched >> part. Thanks. >> >> p = re.compile('#a=*;b=*;c=*;') >> m = p.match(line) >> if m: >> print m.group(), > > IMHO a regex for this is overkill, a combination of string methods such > as split and find should suffice. > > Regards. > -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkpogb0ACgkQLMI5fndAv9jtOwCgj3+YOLfKGvAdyCMOhh4NGgfy x5YAn1ydhUYxGlvC4Z4WlWKaa1gwviSh =jnp1 -----END PGP SIGNATURE----- -- http://mail.python.org/mailman/listinfo/python-list