$re = '/(?i:\b(?:m(?:s(?:ysaccessobjects|ysaces|ysobjects|ysqueries|ysrelationships|ysaccessstorage|ysaccessxml|ysmodules|ysmodules2|db)|aster\.\.sysdatabases|ysql\.db)\b|s(?:ys(?:\.database_name|aux)\b|chema(?:\W*\(|_name\b)|qlite(_temp)?_master\b)|d(?:atabas|b_nam)e\W*\(|information_schema\b|pg_(catalog|toast)\b|northwind\b|tempdb\b))/';
$str = 'msysaccessobjects
msysaces
msysobjects
msysqueries
msysrelationships
msysaccessstorage
msysaccessxml
msysmodules
msysmodules2
msdb
mysql.db
master..sysdatabases
sys.database_name
sysaux
schema_name
sqlite_temp_master
database(
db_name(
information_schema
pg_catalog
pg_toast
northwind
tempdb
';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php