Imports System.Text.RegularExpressions

Public Class frmRegexEditor
    Public RegexString As String

    Public Sub New(RegexString As String)
        ' Dieser Aufruf ist für den Designer erforderlich.
        InitializeComponent()

        ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
        Me.RegexString = RegexString
    End Sub

    Private Sub RegexEditor_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        txtRegex.Text = RegexString
    End Sub

    Private Sub btnTest_Click(sender As Object, e As EventArgs) Handles btnTest.Click
        Try
            Dim oTestString As String = txtTest.Text

            If Regex.IsMatch(oTestString, txtRegex.Text) Then
                labelResult.Text = "Test String ist gültig."
            Else
                labelResult.Text = "Test String ist nicht gültig."
            End If
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Regex Test")
        End Try
    End Sub

    Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        RegexString = txtRegex.Text
    End Sub
End Class
