수

정규 표현식으로 필터링

· 2019-02-07 (목) 19:19:30 · 3109

정규 표현식으로 필터링

정규식을 작성하여 검색 대상을 정확하게 찾을 수 있습니다.

정규식은 문자열 쿼리에만 사용할 수 있습니다 .

"주소"필드가 문자 "S"로 시작하는 문서 만 찾으려면 다음과 같은 정규식을 사용하십시오 /^S/.

예

주소가 문자 "S"로 시작하는 문서 찾기 :

var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/";

MongoClient.connect(url, function(err, db) {
  if (err) throw err;
  var dbo = db.db("mydb");
  var query = { address: /^S/ };
  dbo.collection("customers").find(query).toArray(function(err, result) {
    if (err) throw err;
    console.log(result);
    db.close();
  });
});

댓글을 작성하시려면 로그인이 필요합니다.

개발자팁

5,404건

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
웹서버 19-08-05 조회 4,896
PHP 19-06-24 조회 3,232
PHP 19-06-09 조회 3,884
MySQL 19-04-01 조회 4,913
jQuery 19-03-20 조회 4,293
node.js 19-02-12 조회 3,399
node.js 19-02-12 조회 3,132
node.js 19-02-12 조회 3,395
node.js 19-02-07 조회 3,370
node.js 19-02-07 조회 3,110
node.js 19-02-07 조회 3,246
node.js 19-02-04 조회 2,996
node.js 19-02-04 조회 2,968
node.js 19-02-04 조회 3,415
node.js 19-01-31 조회 2,517
node.js 19-01-31 조회 2,671
node.js 19-01-31 조회 3,164
node.js 19-01-28 조회 2,932
node.js 19-01-28 조회 2,997
node.js 19-01-28 조회 2,842
node.js 19-01-22 조회 3,192
node.js 19-01-22 조회 2,930
node.js 19-01-22 조회 3,387
node.js 19-01-16 조회 2,806
node.js
[node.js]
19-01-16 조회 2,717
node.js 19-01-16 조회 9,378
node.js 19-01-12 조회 4,447
node.js 19-01-12 조회 3,081
node.js 19-01-12 조회 3,195
node.js 19-01-11 조회 2,738