using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?:(Dim|Public|Private) )(?:(WithEvents) )?(?:(?:(?!Declare)(?!Type)(?!Enum)(?!Const)(\w*))(\(\))?)(?: As )?(?:(New) )?(\w*)(, [\w ,\(\)]*)?";
string input = @"Attribute VB_Name = ""mdl_WbkInits""
Option Compare Database
Public WithEvents ue_u23 As New String, soumeth_34ing as somethnig, asi As Anthere item, Maybe lastOne
Public ueu As Variant
Dim ueu
Public Declare Function IIDFromString Lib ""ole32"" (ByVal lpsz As Long, ByRef lpiid As UUID) As Long
Private Declare Function IIDFromString Lib ""ole32"" (ByVal lpsz As Long, ByRef lpiid As UUID) As Long
Private Declare PtrSafe Function FindWindowEx Lib ""user32"" Alias ""FindWindowExA"" (ByVal hWnd1 As Long, ByVal hwnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Type UUID 'GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type
Public Enum e_ControlEventCatch
e_onClick
e_onChange
e_onUpdate
e_onUpdated
e_onDblClick
e_onFocus
e_onExtClick
e_onExtDblClick
e_onActivate
e_onDeActivate
End Enum
Public Const IID_IDispatch As String = ""{00020400-0000-0000-C000-000000000046}""
Const OBJID_NATIVEOM As Long = &HFFFFFFF0
";
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