I am reading a text file and want to use regex below to pull out numbers with exactly 5 digit, ignoring alphabets.
Try this...
var str = 'f 34 545 323 12345 54321 123456',
matches = str.match(/d{5}/g);
console.log(matches); // ["12345", "54321"]
jsFiddle.
The word boundary
is your friend here.
Update
My regex will get a number like this 12345
, but not like a12345
. The other answers provide great regexes if you require the latter.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…