2013-05-02 87 views
4
^(([^<>()[\]\\.,;:\[email protected]\"]+(\.[^<>()[\]\\.,;:\[email protected]\"]+)*)|(\".+\")) 
    @((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.) 
    +[a-zA-Z]{2,}))$ 

我只能理解正則表達式的部分,但不是全部的表情,像有人能解釋這個電子郵件正則表達式意味着

([^<>()[\]\\.,;:\[email protected]\"]+(\.[^<>()[\]\\.,;:\[email protected]\"]+)*)

匹配一個或多個字符的不是人物

<>()[\]\\.,;:\[email protected]\" \\ Not sure what this [\]\\ and \[email protected]\ means 

我可以理解一些其他部分,但不能作爲一個單一的實體。

+0

你從哪裏得到的?它是一個傳遞給'new RegExp'的字符串,還是你忽略了文字分隔符? – Bergi 2013-05-02 18:14:23

+0

我正在使用JavaScript驗證,並且遇到它它被用來測試'電子郵件地址'我試圖理解它,但徒勞無功 – 2013-05-02 18:16:23

+0

http://www.myezapp.com/apps/dev/regexp/show .ws將其插入此處以便捕獲組等的視覺分析。這裏是你的:http://tinyurl.com/ccuqrwk – asawyer 2013-05-02 18:16:34

回答

5

什麼先在這裏你去:

^(
    (
     [^<>()[\]\\.,;:\[email protected]\"]+ // Disallow these characters any amount of times 
     (
      \. // Allow dots 
      [^<>()[\]\\.,;:\[email protected]\"]+ // Disallow these characters any amount of times 
     )* // This group must occur once or more 
    ) 
    | // or 
    (\".+\") // Anything surrounded by quotes (Is this even legal?) 
) 
@ // At symbol is litterally that 
(
    // IP address 
    (
     \[ // Allows square bracket 
     [0-9]{1,3} // 1 to three digits (for an IP address 
     \. // Allows dot 
     [0-9]{1,3} // 1 to three digits (for an IP address 
     \. // Allows dot 
     [0-9]{1,3} // 1 to three digits (for an IP address 
     \. // Allows dot 
     [0-9]{1,3} // 1 to three digits (for an IP address 
     \] // Square bracket 
    ) 
    | // OR a domain name 
    (
     ([a-zA-Z\-0-9]+\.) // Valid domain characters are a-zA-Z0-9 plus dashes 
     + 
     [a-zA-Z]{2,} // The top level (anything after the dot) must be at least 2 chars long and only a-zA-Z 
    ) 
)$ 
+0

感謝您的詳細解釋。 – 2013-05-02 18:42:57

+0

+1非常詳盡的答案。 – Orbling 2013-05-02 19:18:46

4

「不知道這是什麼[\]\\\[email protected]\"意味着」

\]是逃脫]
\\被轉義\
\s是任何空白
@@
\"被轉義"

「什麼是+意味着」

+意味着「一個或多個」的+

5

下面是一個容易看到debuggex插圖。 COM

First group

Second Group

+0

真棒網站!據此,我的姓氏(我無法控制)的撇號電子郵件地址不會通過此正則表達式。 – DOK 2013-05-02 18:50:59

+1

你的圖像實際上是關閉的,因爲當你複製和粘貼正則表達式時,你會得到一堆OP添加的空白,所以我們不需要雙面滾動。儘管酷的網站,書籤。這裏更新:http://tinyurl.com/cklksdd – smerny 2013-05-02 19:07:06

相關問題