regexxslt-2.0marklogic

does MarkLogic Regex support include support for \b for word boundaries?


I am trying to use the XQuery function analyze-string() and I want to find the start of a word. I discovered "\b" is supposed to do this for me. But I could not get it to work.

I then found an example that I am told is supposed to work in MarkLogic:

let $text := "This is a test. b is a letter. Bob is a name."
return 
  fn:matches($text, "\bb")

But again I just get an "Illegal Expression" error message.

Does MarkLogic NOT support word boundary detection?


Solution

  • No, MarkLogic does not include support for \b word boundaries.

    XSLT 2.0 regex does not include \b word boundaries.

    I asked a similar question years ago about alternatives to word boundary for XSLT 2.0 years ago.

    You could try applying:

    fn:matches($text, "(^|\W)b($|\W)")