regular expression to match exactly 5 digits

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(/\b\d{5}\b/g); console.log(matches); // [“12345”, “54321”] jsFiddle. The word boundary \b is your friend here. Update My regex will get a number … Read more

using $and with $match in mongodb

$and with $match works just fine. You have syntax errors in your query. Try this. db.test.aggregate([ { $match: { $and: [ {type: {$in: [“TOYS”]}}, {type: {$nin: [“BARBIE”]}}, {time: {$lt:ISODate(“2013-12-09T00:00:00Z”)}} ] } } ]) And for what you are trying to do, you do not need an $and.

JavaScript error: “val.match is not a function”

I would say that val is not a string. I get the val.match is not function error for the following var val=12; if(val.match(/^s+$/) || val == “”){ document.write(“success: ” + val); } The error goes away if you explicitly convert to a string String(val) var val=12; if(String(val).match(/^s+$/) || val == “”){ document.write(“success: ” + val); … Read more