Hi there,

I am working on a project and want to resolve invalid form submition. i want to create a regular expression which can check each form value that must not have any string like as: '"abc.Xyz
What exactly the regular expression should be?, for more information please feel free to ask me.

Does that mean it can have upper case? or that pattern should not be different, as in abc.xyz? That would leave only expressions like abc.abc? But that does not make to much sense. Then could it be a pattern abc.xyz, where xyz<>abc? If so, the pattern would be:

Imports System.Text.RegularExpressions

Module Module1

Sub Main()
    Dim sPattern As String = _
        "(?<ABC>(?<A>[a-z])(?<B>(?!\k<A>)[a-z])(?!\k<A>|\k<B>)[a-z])"
    Dim rePattern As New Regex( _
        sPattern + "\.(?!\k<ABC>)" + sPattern)

    Do
        Console.WriteLine("Text validation")
        Console.WriteLine("Text should be like 'abc.xyz'")
        Console.WriteLine("Text not should be like 'abc.Xyz' ")
        Console.WriteLine("Enter your text and press 'CR' (blank to exit): ")
        Dim e1 As String = Console.ReadLine()
        If e1.Length = 0 Then Exit Do
        Console.WriteLine()
        Dim m As Match = rePattern.Match(e1)
        If m.Success Then
            Console.WriteLine("Right ! " + m.ToString)
        Else
            If LCase(e1) <> e1 Then
                Console.WriteLine("Letters should be in lower case.")
            End If
            Console.WriteLine(e1 + " does not match, try again.")
        End If
        Console.WriteLine("")
    Loop
End Sub

End Module

A handy reference for regular expressions can be found here. It also includes an area for interactive testing of regular expressions. You can use the provided sample text or paste your own sample text and refine the expression until it gives you the results you want.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.