[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Python regex
- Subject: [ale] Python regex
- From: cfowler at outpostsentinel.com (Christopher Fowler)
- Date: Sat, 09 Sep 2006 15:27:04 -0400
I'm in the process of converting a Perl module to a Python equivalent so
it can be used in Python programs. I'm not exactly a pro with Python.
I may need a bit of help.
One thing I love about Perl is regular expression support.
I'm not sure how I can do the same in Python. The issue here is that
I connect to a master database to get a connection string for an
organizational database. I now need to connect to that database.
Below is the string that comes from the connect_string column:
jdbc:mysql://127.0.0.1/AC_DEMO
In Perl I might do the following to extract what I need:
connection_string =~ m/mysql:\/\/(.+?)/\(.+?)$/;
$host = $1
$db = $2
Can someone tell me how I can do the equivalent in Python?
Thanks,
Chris