Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
Created·2022-11-13 14:24
Updated·2022-11-13 14:25
Flavor·PCRE2 (PHP)

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

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