[Tutor] Which string operation is best to extract text from database string?

Sean Carolan scarolan at gmail.com
Wed Oct 27 18:45:23 CEST 2010

Forgive me for the newbie question; I'm sure there must be an easy way
to do this in python:

I have a database string that I'm grabbing from a file with readlines():

db.url=jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS = (PROTOCOL =
TCP)(HOST = server.company.com)(PORT =1521)) (ADDRESS = (PROTOCOL =
TCP)(HOST = server.company.com)(PORT = 1521)) (ADDRESS = (PROTOCOL
=TCP)(HOST = server.company.com)(PORT = 1521)) (LOAD_BALANCE = ON)
180) (DELAY = 5))))

I want to extract the service name, PROD2 from the string.  Normally
I'd do this with sed or awk, but I'm trying to get away from using
OS-dependent tools with Popen, etc.  What would be the most efficient
way to grab "PROD2" from this string of text?

More information about the Tutor mailing list