Reputation: 91
can anyone please help me to figure Regex
attribute for string field.
I want my string should be in format of FirstName@LastName
thats is it.. I require only one special char in between and rest all alphabets only..
Upvotes: 2
Views: 73
Reputation: 18763
If you want to accept any non-alphanumeric characters in the middle, like $,@,_,-
etc, you can use the following,
[a-zA-Z]+[^a-zA-Z\d\s][a-zA-Z]+
it will match all these among others,
FirstName@LastName
FirstName-LastName
FirstName_LastName
FirstName$LastName
FirstName:LastName
If you want to match whitespace
in between as well then simply remove \s
from above expression.
Hope it helps.
Upvotes: 1