You can use anchors, as
fn:matches("I am learning regex","^re$")
7.6.2 fn:matches of https://www.w3.org/TR/xpath-functions/#flags says:
Unless the metacharacters ^ and $ are used as anchors, the string is
considered to match the pattern if any substring matches the pattern.
But if anchors are used, the anchors must match the start/end of the
string (in string mode), or the start/end of a line (in multiline
mode).
Note:
This is different from the behavior of patterns in [XML Schema Part 2:
Datatypes Second Edition], where regular expressions are implicitly
anchored.
On Fri, Oct 13, 2017 at 3:19 PM, <[email protected]> wrote:
> Hi All,
>
>
>
> How to match exact word using fn:matches and regex.
>
>
>
> Example : fn:matches(“I am learning regex”,”re”)
>
> Above statement returning true as it is matching with “regex” but I want
> it should match only when string found exact keyword.
>
>
>
> Regards,
>
> Vikas Singh
>
>
>
> This e-mail and any files transmitted with it are for the sole use of the
> intended recipient(s) and may contain confidential and privileged
> information. If you are not the intended recipient(s), please reply to the
> sender and destroy all copies of the original message. Any unauthorized
> review, use, disclosure, dissemination, forwarding, printing or copying of
> this email, and/or any action taken in reliance on the contents of this
> e-mail is strictly prohibited and may be unlawful. Where permitted by
> applicable law, this e-mail and other e-mail communications sent to and from
> Cognizant e-mail addresses may be monitored.
>
> _______________________________________________
> General mailing list
> [email protected]
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general