<?xml version="1.0"?>
<page xmlns="http://projectmallard.org/1.0/"
      type="topic"
      style="function"
      xmlns:api="http://projectmallard.org/experimental/api/"
      xmlns:ui="http://projectmallard.org/experimental/ui/"
      id="bson_append_regex">
  <info>
    <link type="guide" xref="bson_t" group="function"/>
  </info>
  <title>bson_append_regex()</title>

  <section id="synopsis">
    <title>Synopsis</title>
    <synopsis><code mime="text/x-csrc"><![CDATA[bool
bson_append_regex (bson_t     *bson,
                   const char *key,
                   int         key_length,
                   const char *regex,
                   const char *options);
]]></code></synopsis>
  </section>

  <section id="parameters">
    <title>Parameters</title>
    <table>
      <tr><td><p>bson</p></td><td><p>A <code xref="bson_t">bson_t</code>.</p></td></tr>
      <tr><td><p>key</p></td><td><p>An ASCII C string containing the name of the field.</p></td></tr>
      <tr><td><p>key_length</p></td><td><p>The length of <code>key</code> in bytes, or -1 to determine the length with <code>strlen()</code>.</p></td></tr>
      <tr><td><p>regex</p></td><td><p>An ASCII string containing the regex.</p></td></tr>
      <tr><td><p>options</p></td><td><p>An optional string containing the regex options as a string.</p></td></tr>
    </table>
  </section>

  <section id="description">
    <title>Description</title>
    <p>Appends a new field to <code>bson</code> of type BSON_TYPE_REGEX. <code>regex</code> should be the regex string. <code>options</code> should contain the options for the regex.</p>

    <p>Valid characters for <code>options</code> include:</p>

    <list>
      <item><p><code>'i'</code> for case-insensitive.</p></item>
      <item><p><code>'m'</code> for multiple matching.</p></item>
      <item><p><code>'x'</code> for verbose mode.</p></item>
      <item><p><code>'l'</code> to make \w and \W locale dependent.</p></item>
      <item><p><code>'s'</code> for dotall mode ('.' matches everything)</p></item>
      <item><p><code>'u'</code> to make \w and \W match unicode.</p></item>
    </list>
  </section>

  <section id="return">
    <title>Returns</title>
    <p>true if the operation was applied successfully, otherwise false and <code>bson</code> should be discarded.</p>
  </section>
</page>
