title: MongoDB $regex query for "end with" particular char
body: <p>I am not able to remove object from an array named <code>Matrix</code> for a Key match</p>
  
  <pre><code> BasicDBObject where = new BasicDBObject();
      where.put("INSTITUTION_ID", instid);
      where.put("RuleID", ruleid);
  
      BasicDBObject obj1 = new BasicDBObject();
      obj1.put("Matrix.Key",new BasicDBObject("$regex","/"+json.getString("Code")+"$/"));
  
  collection.update(where,new BasicDBObject("$pull", obj1));
  </code></pre>
  
  <p>The code above is not removing object from array. The structure of the array can be found below</p>
  
  <pre><code>"Matrix" : [
          {
              "Key" : "6M",
              "value" : "Queue"
          },
          {
              "Key" : "6N",
              "value" : "Queue"
          },
          {
              "Key" : "6O",
              "value" : "Queue"
          }]
  </code></pre>