fn:analyze-string( $in as xs:string?, $regex as xs:string, [$flags as xs:string] ) as element(s:results)
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.
Parameters | |
---|---|
in | The string to start with. |
regex | The regular expression pattern to match. |
flags | The flag representing how to interpret the regular expression. One of "s", "m", "i", or "x", as defined in http://www.w3.org/TR/xpath-functions/#flags. |
fn:analyze-string('Tom Jim John',"Jim") => <s:analyze-string-result> <s:non-match>Tom </s:non-match> <s:match>Jim</s:match> <s:non-match> John</s:non-match> </s:analyze-string-result>
fn:analyze-string('Tom Jim John',"(Jim)") => <s:analyze-string-result> <s:non-match>Tom </s:non-match> <s:match> <s:group nr="1">Jim</s:group> </s:match> <s:non-match> John</s:non-match> </s:analyze-string-result>
fn:analyze-string('Tom Jim John',"((Jim) John)") => <s:analyze-string-result> <s:non-match>Tom </s:non-match> <s:match> <s:group nr="1"> <s:group nr="2">Jim</s:group> John </s:group> </s:match> </s:analyze-string-result>
fn:analyze-string("http://example.com/", "\w+") => <result xmlns="http://www.w3.org/2005/xpath-functions"> <match>http</match> <non-match>://</non-match> <match>example</match> <non-match>.</non-match> <match>com</match> <non-match>/</non-match> </result>