Regular Expressions 101

Community Library Entry

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 - 2 years ago (Last modified 2 years ago)