Code Repo    |     RSS
MD's Technical Sharing



Saturday, April 4, 2009

Validate text using RegEx

'Email address:
Regex.IsMatch(
Me.txtEmail.Text, "\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*")

'Alpha-numeric (no space):
Regex.IsMatch(
Me.txtUsername.Text, "^[0-9a-zA-Z]+$")

'Alpha-numeric with space, at least 5 chars:
Regex.IsMatch(
Me.txtUsername.Text, "[0-9a-zA-Z' ']{5,} )

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.