xquery version "1.0"; let $s := "aabbcc" return <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>regex-anomaly.xqy</title> </head> <body> <h1>regex-anomaly.xqy</h1> <p> Demonstrate a MarkLogic regular expression bug. </p> <p> Test string is "{$s}" </p> <p> <b>Works correctly:</b> match as many "a"s as you can (greedily), then one or more "b", and replace with an "x", we expect "xcc": </p> <blockquote> replace($s, "^a*b+", "x"): "{replace($s, "^a*b+", "x")}" </blockquote> <p> <b>Fails:</b> note how the question mark turns off greedy matching for the "+" sign, the result should be the same "xcc", but I am seeing "xbcc": </p> <blockquote> replace($s, "^a*?b+", "x"): "{replace($s, "^a*?b+", "x")}" </blockquote> <p> I tested this same expression using Perl and using Saxon, and they both give the expected results "xcc" in both cases. </p> </body> </html>
Chris Maloney NIH/NLM/NCBI (Contractor) Building 45, 5AN.36D-17 301-443-6461
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
