2

I want to filter the data from db with the help of regex that count the digits.i have a regex that count digits but its not working in mongodb query getting some error or empty result.regex is below "^(\d {1})$" . Don't know how to how to use this regex in the mongodb query.anyone can help ? Thanks

let regex = new RegExp("^(\d {1})$", 'i');
return placeStorage.list({ price: { $regex: regex } })
    .then(places => {
        return places
    })

i want the result that inculdes the places which have the price digit according the digit in the regex. for example if put 99 then it should return the value that includes the price which have price with maximum 2 digits like 99 or below this not more than this like 100 or more than this should not be return

Hammad ul Hasan
  • 306
  • 3
  • 15
  • 3
    Possible duplicate of [Why do regex constructors need to be double escaped?](https://stackoverflow.com/questions/17863066/why-do-regex-constructors-need-to-be-double-escaped) – CertainPerformance May 03 '19 at 07:37
  • Possible duplicate of [MongoDB Regex Search on Integer Value](https://stackoverflow.com/questions/2908100/mongodb-regex-search-on-integer-value) – Ashh May 03 '19 at 09:00

0 Answers0