[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 419
  • Last Modified:

Regular Expression - Allow White Spaces

I have an asp.net control using a regular expression for validation, it is for an email address.  It allows alphanumeric and also allows 1 character domain names.  

I need to modify it to also allow white spaces at the beginning and end of it (but not anywhere in the middle).  Not sure how to do this, I have tried and have failed miserably thus far.  

Here is the current expression which works as desired but new request for white spaces means it needs to be updated:

Public Const REG_EMAIL As String = "^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"

Thanks in advance, I hope someone can help.

0
kruegerste
Asked:
kruegerste
  • 2
  • 2
1 Solution
 
käµfm³d 👽Commented:
"^\s*\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*\s*$"
0
 
kruegersteAuthor Commented:
Awesome, thanks. Works perfect.  
0
 
kruegersteAuthor Commented:
Awesome, thanks. Works perfect.  
0
 
käµfm³d 👽Commented:
NP. Glad to help :)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now