정규 표현식으로 필터링

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

정규 표현식으로 필터링

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

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

"주소"필드가 문자 "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,403건

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

+
분류 제목 글쓴이 날짜 조회
PHP 19-06-24 조회 3,181
PHP 19-06-09 조회 3,801
MySQL 19-04-01 조회 4,852
jQuery 19-03-20 조회 4,237
node.js 19-02-12 조회 3,338
node.js 19-02-12 조회 3,071
node.js 19-02-12 조회 3,333
node.js 19-02-07 조회 3,294
node.js 19-02-07 조회 3,054
node.js 19-02-07 조회 3,186
node.js 19-02-04 조회 2,921
node.js 19-02-04 조회 2,910
node.js 19-02-04 조회 3,343
node.js 19-01-31 조회 2,451
node.js 19-01-31 조회 2,598
node.js 19-01-31 조회 3,095
node.js 19-01-28 조회 2,856
node.js 19-01-28 조회 2,939
node.js 19-01-28 조회 2,767
node.js 19-01-22 조회 3,110
node.js 19-01-22 조회 2,852
node.js 19-01-22 조회 3,290
node.js 19-01-16 조회 2,721
node.js
[node.js]
19-01-16 조회 2,636
node.js 19-01-16 조회 9,313
node.js 19-01-12 조회 4,373
node.js 19-01-12 조회 2,988
node.js 19-01-12 조회 3,118
node.js 19-01-11 조회 2,692
node.js 19-01-11 조회 4,010