我被困在特殊的問題,我有用戶名字段只有字母數字和。 - 和_是允許的,應始終以字母開頭正則表達式來匹配電子郵件
這裏的例子是接受什麼
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
我做了什麼到現在是
[a-zA-Z0-9]+[._-]{1,1}[a-zA-Z0-9][email protected]
此匹配除的問題,我的所有要求它劑量匹配
[email protected]
[email protected]
但它甚至匹配
[email protected]
不要求我真的沒有得到如何解決這件事我想是
[a-zA-Z0-9]+[._-]{0}[a-zA-Z0-9][email protected]
,但這也沒有解決我的問題,現在它接受像
[email protected]
一切
這是不需要的請幫我
電子郵件的正則表達式很棘手。請參閱本教程http://www.regular-expressions.info/email.html – flowfree
這是什麼 - 驗證*任何*電子郵件地址,或檢查特定網站的用戶名? –
如果你還沒有,你可以考慮使用[Regex分析器](http://stackoverflow.com/questions/772594/regular-expression-explained-with-words)通過你的正則表達式對樣本數據。正則表達式教練告訴我*沒有在7 *上爲someone @ mydomain.com進行子匹配,並突出顯示了[._-] {1,1}'塊。 –