3
Contributors
10
Replies
18
Views
5 Years
Discussion Span
Last Post by Reverend Jim
0

The easiest way would be to split it into three strings as mystring.Split("\") then validate each field separately. A more complicated way would be to use a regular expression.

0

The easiest way would be to split it into three strings as mystring.Split("\") then validate each field separately. A more complicated way would be to use a regular expression.

can you teach me on how regex works?

0

I know this is not what you asked but if you just want to check if it is a valid date then you can use the isdate() function.

0

Well don't I just feel like a complete moron? isdate() (DOH!).

As for regex, I use them so infrequently that when I need a particular one I can usually just find it online or in a book. Wrox Press Beginning Regular Expressions by Andrew Watt is excellent. When you discover that this "intro" book is almost 800 pages you'll get the idea that regular expressions are non-trivial.

Edited by Reverend Jim: n/a

0

Well don't I just feel like a complete moron? isdate() (DOH!).

As for regex, I use them so infrequently that when I need a particular one I can usually just find it online or in a book. Wrox Press Beginning Regular Expressions by Andrew Watt is excellent. When you discover that this "intro" book is almost 800 pages you'll get the idea that regular expressions are non-trivial.

okay, i found a solution on the date format, while i'm having trouble on validating if the string is numeric in regex.. i tried the Regex(“\d+”), but it didn't work ..

how can i validate it using regex?

0

is it not simpler to us the isnumeric function

okay, but the thing is, I want to use the regex for the validation procedure..
thanks by the way for the comments..

0
Imports System.Text.RegularExpressions

Public Class Form1

    Private Sub btnValidate_Click(sender As System.Object, e As System.EventArgs) Handles btnValidate.Click

        Dim pattern As String = "^(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$"
        Dim regex As New Regex(pattern)

        If regex.IsMatch(txtInput.Text) Then
            MsgBox("is valid")
        Else
            MsgBox("is not valid")
        End If

    End Sub

End Class
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.