using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(Dim|Static)(?: )([\S]*)(\(\))?(?: )?(As)? ?(New)? ?([^\r\t\f\v,]*)(,[\S\s][^\n]*)?";
string input = @"
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
";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
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 C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx