Loading TOC...

MarkLogic Server 11.0 Product Documentation
fn:regex-group

fn:regex-group(
   $group-number as xs:integer
) as xs:string

Summary

While the xsl:matching-substring instruction is active, a set of current captured substrings is available, corresponding to the parenthesized sub-expressions of the regular expression. These captured substrings are accessible using the function regex-group. This function takes an integer argument to identify the group, and returns a string representing the captured substring.

This function is only available in XSLT; it is not available in XQuery or JavaScript.

Parameters
group-number The group number to return.

Usage Notes

The function returns the zero-length string if there is no captured substring with the relevant number. This can occur for a number of reasons:

  1. The number is negative.
  2. The regular expression does not contain a parenthesized sub-expression with the given number.
  3. The parenthesized sub-expression exists, and did not match any part of the input string.
  4. The parenthesized sub-expression exists, and matched a zero-length substring of the input string.

Example

See the examples in the xsl:analyze-string section of the XSLT Specification.

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.