title: Compare fullwidth and halfwidth japanese characters in mongodb by using collation and regex
body: <p>According to <a href="https://docs.mongodb.com/manual/reference/collation/" rel="nofollow noreferrer">the MongoDB documentation</a> and <a href="http://userguide.icu-project.org/collation/customization" rel="nofollow noreferrer">the ICU documentation</a> it should be possible to ignore full-width and half-width difference in Japanese text by utilizing <code>collation</code>.</p>
  
  <p>I tried the following;</p>
  
  <pre><code>{ locale: "ja", caseLevel:true, strength:1} 
  </code></pre>
  
  <p>with different strength but none of them is working.</p>
  
  <pre><code>db.getCollection('mycollection')
          .find({"desc":/ﾊﾞﾝﾄﾞ/})
          .collation({ locale: "ja", caseLevel:true, strength:1})
  </code></pre>
  
  <p>This query cannot get result from the following document;</p>
  
  <pre><code>{
      "desc": "＊EGRパイプバンド外れ"
  }
  </code></pre>
  
  <hr>
  
  <p><strong><em>update</em></strong></p>
  
  <p>Found reason that in MongoDB regex cannot apply collation, so if I use certain match to perform query the result is perfect:</p>
  
  <pre><code>db.getCollection('mycollection')
          .find({"desc":"*EGRﾊﾟｲﾌﾟﾊﾞﾝﾄﾞ外れ???"})
          .collation({ locale: "ja", caseLevel:true, strength:1})
  </code></pre>
  
  <p>This query will return <code>＊EGRパイプバンド外れ</code> this result.</p>
  
  <p>But not if I use regex, any suggestion on it?</p>