I need in my code to verify the validity of an expression entered in a textbox, so I thought to Regex but my problem is that I do not get it.
So here is my expression: [3 Numbers]-[1 character Shift].[1 Number].
for example: 007-L.4
I try with this:
Dim MyRegex As Regex = New Regex("^[0-9]{3}-[a-zA-Z].[O-9]$")
but it does not work
thank you in advance
You have two errors in your pattern:
.
is a metacharacter which matches any character. You need to escape it to\.
to match periods only,O
(the letter) instead of0
(the digit). :-)Here's a the corrected pattern:
(demo)