$re = '/(Dim|Static)(?: )([\S]*)(\(\))?(?: )?(As)? ?(New)? ?([^\r\t\f\v,]*)(,[\S\s][^\n]*)?/m';
$str = '
On Error GoTo Err
Dim obj_AccessApp As Object, Test As xxxy, euaou sai xxx
Set obj_AccessApp = Nothing
Set db_Ref = Nothing
Dim hWndMain As LongPtr
hWndMain = FindWindowEx(0&, 0&, "OMAIN", vbNullString)
Do While hWndMain <> 0
Call z_mGetObjectFromHwnd(hWndMain, obj_AccessApp)
Dim str_DbName As String
str_DbName = ""
On Error Resume Next
str_DbName = obj_AccessApp.CurrentDb.Name
On Error GoTo Err
If str_DbName Like "*\\PPMSupportDb.accdb" Then
On Error Resume Next
obj_AccessApp.CloseCurrentDatabase
obj_AccessApp.Quit
Set obj_AccessApp = Nothing
On Error GoTo 0
Debug.Print "Support item killed"
End If
If str_DbName = "" Then
On Error Resume Next
obj_AccessApp.Quit
Set obj_AccessApp = Nothing
On Error GoTo Err
Debug.Print "Blank item killed"
End If
hWndMain = FindWindowEx(0&, hWndMain, "OMAIN", vbNullString)
Loop
Exit_Default:
Set obj_AccessApp = Nothing
Exit Sub
Err:
MsgBox "GetDatabaseNames" & vbCrLf & vbCrLf & "Err = " & Err.Number & vbCrLf & "Description: " & Err.Description
Resume Exit_Default
';
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