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

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -