<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/fn.analyzeString.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>fn.analyzeString</api:function-name><api:suggest>fn.analyzestring</api:suggest><api:suggest>fn</api:suggest><api:suggest>analyzestring</api:suggest><api:function-link mode="xquery" fullname="fn:analyze-string">/apidoc/8.0/fn:analyze-string.xml</api:function-link><api:function mode="javascript" name="analyzeString" type="builtin" lib="fn" category="StringBuiltins" bucket="W3C-Standard Functions" hidden="false" prefix="fn" namespace="http://www.w3.org/2005/xpath-functions" fullname="fn.analyzeString"><api:summary>
The result of the function is a new element node whose string value is the
original string, but which contains markup to show which parts of the
input match the regular expression.
</api:summary><api:params><api:param name="in" type="xs:string?"><api:param-description>
  The string to start with.
  </api:param-description><api:param-name>in</api:param-name><api:param-type>String?</api:param-type></api:param><api:param name="regex" type="xs:string"><api:param-description>
  The regular expression pattern to match.
  </api:param-description><api:param-name>regex</api:param-name><api:param-type>String</api:param-type></api:param><api:param name="flags" type="xs:string" optional="true"><api:param-description>
  The flag representing how to interpret the regular expression. One of
  "s", "m", "i", or "x", as defined in
  <a href="http://www.w3.org/TR/xpath-functions/#flags" xmlns="http://www.w3.org/1999/xhtml">http://www.w3.org/TR/xpath-functions/#flags</a>.
  </api:param-description><api:param-name>flags</api:param-name><api:param-type>String</api:param-type></api:param></api:params><api:return>element(s.results)</api:return><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
fn.analyzeString('Tom Jim John',"Jim");

=&gt;
&lt;s:analyze-string-result&gt;
  &lt;s:non-match&gt;Tom &lt;/s:non-match&gt;
  &lt;s:match&gt;Jim&lt;/s:match&gt;
  &lt;s:non-match&gt; John&lt;/s:non-match&gt;
&lt;/s:analyze-string-result&gt;
</pre>
</api:example><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
fn.analyzeString('Tom Jim John',"(Jim)");

=&gt;
&lt;s:analyze-string-result&gt;
  &lt;s:non-match&gt;Tom &lt;/s:non-match&gt;
    &lt;s:match&gt;
      &lt;s:group nr="1"&gt;Jim&lt;/s:group&gt;
    &lt;/s:match&gt;
  &lt;s:non-match&gt; John&lt;/s:non-match&gt;
&lt;/s:analyze-string-result&gt;
</pre>
</api:example><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
fn.analyzeString('Tom Jim John',"((Jim) John)");

=&gt;
&lt;s:analyze-string-result&gt;
  &lt;s:non-match&gt;Tom &lt;/s:non-match&gt;
  &lt;s:match&gt;
    &lt;s:group nr="1"&gt;
    &lt;s:group nr="2"&gt;Jim&lt;/s:group&gt;
    John
    &lt;/s:group&gt;
  &lt;/s:match&gt;
&lt;/s:analyze-string-result&gt;
</pre>
</api:example><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
fn.analyzeString("http://example.com/", "\\w+");
// note that you have to escape the escape character in JavaScript

=&gt;
&lt;result xmlns="http://www.w3.org/2005/xpath-functions"&gt;
  &lt;match&gt;http&lt;/match&gt;
  &lt;non-match&gt;://&lt;/non-match&gt;
  &lt;match&gt;example&lt;/match&gt;
  &lt;non-match&gt;.&lt;/non-match&gt;
  &lt;match&gt;com&lt;/match&gt;
  &lt;non-match&gt;/&lt;/non-match&gt;
&lt;/result&gt;
</pre>
</api:example></api:function></api:function-page>