Using RegEx to Identify parts of a Database Connection String

Posted by David_Jarrett on Stack Overflow See other posts from Stack Overflow or by David_Jarrett
Published on 2010-03-30T12:25:32Z Indexed on 2010/03/30 12:33 UTC
Read the original article Hit count: 229

Filed under:

I'm trying to get to grips with regular expressions:

I have a database connection string and I'd like to use a regular expression to identify specific Keys and Values within it.

For example

server=foo;database=bar;uid=foo;pwd=bar

I'd like something to return "database=bar;" using the 'database' key to identify it, ideally it would be case insensitive. I can do this using normal code, but I think that this is exactly the sort of thing for which regular expressions were designed.

© Stack Overflow or respective owner

Related posts about regex