title: Use of pattern $match $in in aggregate function of Mongo PHP Library
body: <p>I am using Mongo PHP Library in my code: <a href="https://github.com/mongodb/mongo-php-library/" rel="nofollow noreferrer">https://github.com/mongodb/mongo-php-library/</a>
  </p>
  
  <p>I am trying to send following query to MongoDB using aggregate function in Mongo PHP Library:</p>
  
  <blockquote>
    <p>Blockquote</p>
  </blockquote>
  
  <pre><code>db.customers.aggregate(
  {$match: {Country: "India", Email: {$in: [/.*@gmail.com*/,/.*@hotmail.com*/] } } },
  {$group : {_id : {Email: "Email"}, "count" : {$sum : 1} } },
  {$sort : {"count" : -1} }
  )
  </code></pre>
  
  <p>This query works fine on MongoDB Server. But in PHP code it isn't working.</p>
  
  <blockquote>
    <p>Blockquote</p>
  </blockquote>
  
  <pre><code>$query = array(
  ['$match' =&gt; ['Country' =&gt; "India", 
                'Email' =&gt; ['$in' =&gt; ['/.*@gmail.com*/','/.*@hotmail.com*/']]
               ]
  ],
  ['$group' =&gt; ['_id' =&gt; ['Email' =&gt; '$Email']
                'count' =&gt; ['$sum' =&gt; 1]
               ]
  ],
  ['$sort' =&gt; ['count' =&gt; -1]]
  );
  $cursor = $this-&gt;customers-&gt;aggregate($query);
  </code></pre>
  
  
  
  <p>
  $in array is not working with wildcard pattern as above. It doesn't show any error or result. But it works with exact email. How can i mention the pattern in $in array under $match</p>
  
  <p>
  Please suggest how can i submit the wildcard pattern in Mongo PHP library. </p>