Regular Expressions 101

Community Patterns

MSSQL data source and initial catalog

0

Regular Expression
PCRE2 (PHP >=7.3)

/
name="\w+".*connectionString=.*((data source=([\w0-9_\.-]+);|initial catalog=([\w0-9_\.-]+);).*){2}
/
gm

Description

given a connection string to MSSQL server, we want to extract the URL and the name of the database. these are the "data source" and "initial catalog" fields respectively. The regex does not assume an order between those fieldss

Submitted by Noam - a year ago (Last modified a year ago)