I was wondering what the best way to go about parsing "HOST" names out of oracle connection strings. Here is an example connection string:
Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID)))
And I have it in a String
. What is the best way to get "MyHost" returned. Also would be nice if it worked for double connection strings, example:
((Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost1)(PORT=MyPort1)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID1))))(Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost2)(PORT=MyPort2)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID2)))))
Would return "MyHost1" and "MyHost2".
Trying to write a method that takes in a connection string and spits out the host/hosts in an array list of strings.