Regex multiple match substring

You can achieve what you need by using two steps. You could use this regex to validate the format: Working demo Once you validated the right strings you can use a function like this: Output:

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)