I have a windows form, in which i have a textbox. I want to check using Regex that the text inserted does not contain any other character except:
- Alphabetic letters [a-z] or [A-Z]
- Numbers, 0-9
- _ (underscore) or . (Dot)
I have written this line of code which seems to not work properly.
In VB.NET/C#:
Regex.IsMatch(txtCreateDomain.ToString(), "^[a-zA-Z0-9_.]*$")
I want for example to create a variable like below:
C#
bool isValid = Regex.IsMatch(txtCreateDomain.ToString(), "^[a-zA-Z0-9_.]*$")
VB
Dim isValid As Boolean = Regex.IsMatch(txtCreateDomain.ToString(), "^[a-zA-Z0-9_.]*$")
What am i missing?