Imports System.Text.RegularExpressions

Public Class frmRegexEditor
    Public RegexString As String

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

    Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        RegexString = txtRegex.Text
    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
End Class