javascript - RegExp. Search MAC-adress -


'01:32:54:67:89:ab'.match(/(([a-f0-9]{2}):){5}\2/); //null 

why not link group?

if write well, works:

(([a-f0-9]{2}):){5}([a-f0-9]{2}) 

\2 not reference pattern. reference 2nd captured group.

in pattern 89 captured in 2nd group.. search 89.. hence not getting match.

for example:

(["'])\w+\1 match "hello" since both ends on same first match " not match "hello'


Comments

Popular posts from this blog

xslt - Substring before throwing error -

Google Cloud Bigtable Durability/Availability Guarantees -

Android M doze mode and "native" posix socket freezing up -