package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?is)Public(?: ReadOnly)? Property (?<prop>.*?)\(\) As [a-zA-Z]*(?: Implements )?.*? End Property`)
var str = `Imports System.Windows.Forms
Imports System.Drawing
Imports CapReportLib
Imports ReportControls.Database
Imports System.Threading
Imports System.ComponentModel
Public Class Report : Implements IReport
#Region "Fields"
Friend MyReportRunTime As TimeSpan
Friend MyLastException As New Exception("No Errors")
Friend RepParams As New ReportParameters()
Friend Shared DBA As ReportControls.Database.DataAccess
Private lastResult As New ReportResult(False, New TimeSpan, String.Empty)
Private Shared delRunReport As IReport.Execute = Nothing
Private repSync As ISynchronizeInvoke
Private repThread As Thread
Private repHandler As IReport.ReportHandler
Private repParamsSync As ISynchronizeInvoke
Private threadIsRunning As Boolean = False
Private Delegate Sub EnableCsvHandler(ByVal enable As Boolean, ByVal value As String)
Private enableCsv As EnableCsvHandler
Private csvData As String = String.Empty
Private startDate As Date = Now
Private endDate As Date = Now
Private origin As ReportControls.Types.OriginItem
#End Region
#Region "Threading"
Private Sub RunReportThread()
threadIsRunning = True
Dim rs = ExecuteReport()
If repThread.ThreadState <> ThreadState.AbortRequested Then
repSync.Invoke(repHandler, New Object() {rs})
repParamsSync.Invoke(enableCsv, New Object() {True, csvData})
End If
threadIsRunning = False
End Sub
Public Sub ExecuteReportThread() Implements IReport.ExecuteReportThread
repParamsSync = RepParams
enableCsv = AddressOf RepParams.EnableCsvExport
repThread = New Thread(AddressOf RunReportThread)
repThread.Start()
End Sub
Public Sub SetReportHandler(ByVal rh As IReport.ReportHandler) Implements IReport.SetReportHandler
repHandler = rh
End Sub
Public Sub StopReport() Implements IReport.StopReport
If repThread Is Nothing Then Return
If repThread.IsAlive Then
repThread.Abort()
End If
End Sub
Public Sub SetSyncInvoke(ByVal syn As ISynchronizeInvoke) Implements IReport.SetSyncInvoke
repSync = syn
End Sub
Public Sub SetReportHandler(ByVal rh As IReport.ReportHandler, ByVal syn As ISynchronizeInvoke) _
Implements IReport.SetReportHandler
repSync = syn
repHandler = rh
End Sub
#End Region
#Region "Initialize"
Public Sub SetOutPut(ByVal pnlControls As Panel) Implements IReport.SetOutPut
RepParams.Parent = pnlControls
RepParams.Dock = DockStyle.Fill
RepParams.Show()
End Sub
Public Sub SetReportDataAccess(ByVal connectionString As String) Implements CapReportLib.IReport.SetReportConnectionString
SetDataAccess(New ReportControls.Database.DataAccess(connectionString))
End Sub
Public Sub SetDataAccess(ByVal db As DataAccess)
DBA = db
SetOrigins()
End Sub
Private Sub SetOrigins()
RepParams.OriginSelector.SetConnectionString(DBA.ConnectionString)
End Sub
Public Sub SetReportExecute(ByVal exc As IReport.Execute) Implements IReport.SetReportExecute
delRunReport = exc
End Sub
Public Sub Dispose() Implements IReport.Dispose
DBA.Dispose()
RepParams.Dispose()
End Sub
#End Region
#Region "Run Report"
Public Function ExecuteReport() As ReportResult Implements IReport.ExecuteReport
RepParams.CsvButton1.EnableCsvExport(False, String.Empty)
Dim success As Boolean = True
Dim startRun = Now
Dim repData As String = String.Empty
Try
If HasValidParametersSelected Then
Dim rep As New DocsStoredReport(startDate, endDate)
repData = rep.Execute(origin, RepParams.ChkRunOriginal.Checked)
csvData = rep.CsvOutput
If Not threadIsRunning Then
RepParams.CsvButton1.EnableCsvExport(True, rep.CsvOutput)
End If
End If
Catch ex As Exception
success = False
MyLastException = ex
End Try
Dim endRun = Now
lastResult = New ReportResult(success, endRun - startRun, repData)
Return lastResult
End Function
Friend Shared Sub RunReport()
If delRunReport Is Nothing Then Return
delRunReport.Invoke()
End Sub
#End Region
#Region "Format Output"
Public Sub FormatText(ByRef disp As RichTextBox) Implements IReport.FormatText
Dim iFont As New Font("Courier New", 12, FontStyle.Regular, GraphicsUnit.Pixel)
disp.SelectAll()
disp.SelectionFont = iFont
'disp.SelectionAlignment = HorizontalAlignment.Center
If disp.Find(DocsStoredReport.Header) = -1 Then Return
disp.SelectionStart = disp.Find(DocsStoredReport.Header)
disp.SelectionLength = DocsStoredReport.Header.Length
iFont = New Font("Courier New", 18, FontStyle.Bold, GraphicsUnit.Pixel)
disp.SelectionFont = iFont
'disp.SelectionAlignment = HorizontalAlignment.Center
disp.SelectionStart = disp.Find(DocsStoredReport.DateRange)
disp.SelectionLength = DocsStoredReport.DateRange.Length
iFont = New Font("Courier New", 18, FontStyle.Bold, GraphicsUnit.Pixel)
disp.SelectionFont = iFont
'disp.SelectionAlignment = HorizontalAlignment.Center
disp.SelectionStart = disp.Find(DocsStoredReport.SubHeader)
disp.SelectionLength = DocsStoredReport.SubHeader.Length
iFont = New Font("Courier New", 12, FontStyle.Bold Xor FontStyle.Underline, GraphicsUnit.Pixel)
disp.SelectionFont = iFont
'disp.SelectionAlignment = HorizontalAlignment.Center
disp.SelectionStart = disp.Find("Export Files")
disp.SelectionLength = "Export Files".Length
iFont = New Font("courier new", 12, FontStyle.Bold, GraphicsUnit.Pixel)
disp.SelectionFont = iFont
disp.SelectionStart = disp.Find(ExportFile.HeaderRow(False))
disp.SelectionLength = ExportFile.HeaderRow(False).Length
iFont = New Font("Courier New", 12, FontStyle.Bold Xor FontStyle.Underline, GraphicsUnit.Pixel)
disp.SelectionFont = iFont
End Sub
Public Sub FormatText(ByRef lbl As Label) Implements IReport.FormatText
End Sub
Public Sub FormatTreeView(ByRef trv As TreeView) Implements IReport.FormatTreeView
End Sub
Public ReadOnly Property DisplayXmlRootNode() As Boolean Implements IReport.DisplayXmlRootNode
Get
Return True
End Get
End Property
Public ReadOnly Property AttributeDisplay() As XmlAttributeDisplay Implements IReport.AttributeDisplay
Get
Return XmlAttributeDisplay.None
End Get
End Property
Public ReadOnly Property AttributeDelimiter() As String Implements IReport.AttributeDelimiter
Get
Return " | "
End Get
End Property
#End Region
#Region "Information"
Public ReadOnly Property ReportName() As String Implements IReport.ReportName
Get
Return "Documents Stored"
End Get
End Property
Public ReadOnly Property ReportDescription() As String Implements IReport.ReportDescription
Get
Return "Totals for the documents stored"
End Get
End Property
Public ReadOnly Property ReportExportType() As ExportType Implements IReport.ReportExportType
Get
Return ExportType.Text
End Get
End Property
Public ReadOnly Property HasValidParametersSelected() As Boolean Implements IReport.HasValidParametersSelected
Get
endDate = RepParams.DateRange.GetEndDate
startDate = RepParams.DateRange.GetStartDate
origin = RepParams.OriginSelector.SelectedValue
Return RepParams.ValidParameters
End Get
End Property
Public ReadOnly Property ReportHeader() As String Implements IReport.ReportHeader
Get
Return String.Empty
End Get
End Property
Public Property LastError() As Exception Implements IReport.LastError
Get
Return MyLastException
End Get
End Property
Public ReadOnly Property ReportResults() As ReportResult Implements IReport.ReportResults
Get
Return lastResult
End Get
End Property
Public ReadOnly Property AllowExport() As Boolean Implements IReport.AllowExport
Get
Return True
End Get
End Property
Public ReadOnly Property Parameters() As String Implements IReport.Parameters
Get
Dim params As Object() = New Object() _
{vbNewLine, RepParams.DateRange.GetStartDate.ToShortDateString, _
RepParams.DateRange.GetEndDate.ToShortDateString}
Return String.Format("StartDate: {1}{0}EndDate: {2}{0}", params)
End Get
End Property
Public Overloads Function ToString() As String Implements IReport.ToString
Return ReportName
End Function
#End Region
End Class
`
for i, match := range re.FindAllString(str, -1) {
fmt.Println(match, "found at index", i)
}
}
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 Golang, please visit: https://golang.org/pkg/regexp/