정규 표현식으로 필터링

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

정규 표현식으로 필터링

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

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

"주소"필드가 문자 "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,172
PHP 19-06-09 조회 3,783
MySQL 19-04-01 조회 4,838
jQuery 19-03-20 조회 4,231
node.js 19-02-12 조회 3,319
node.js 19-02-12 조회 3,052
node.js 19-02-12 조회 3,318
node.js 19-02-07 조회 3,286
node.js 19-02-07 조회 3,041
node.js 19-02-07 조회 3,170
node.js 19-02-04 조회 2,908
node.js 19-02-04 조회 2,896
node.js 19-02-04 조회 3,326
node.js 19-01-31 조회 2,437
node.js 19-01-31 조회 2,584
node.js 19-01-31 조회 3,080
node.js 19-01-28 조회 2,841
node.js 19-01-28 조회 2,925
node.js 19-01-28 조회 2,749
node.js 19-01-22 조회 3,090
node.js 19-01-22 조회 2,843
node.js 19-01-22 조회 3,278
node.js 19-01-16 조회 2,713
node.js
[node.js]
19-01-16 조회 2,624
node.js 19-01-16 조회 9,301
node.js 19-01-12 조회 4,365
node.js 19-01-12 조회 2,985
node.js 19-01-12 조회 3,113
node.js 19-01-11 조회 2,684
node.js 19-01-11 조회 4,001