Hi, Johan does not seem to have got any answer on this one. Is it a hard limit, to be less than 1,500 chars for a regex? Is this limit going to be kept in ML9?
Just curious... Regards, -- Florent Georges http://fgeorges.org/ http://h2oconsulting.be/ On 22 August 2016 at 13:41, Florent Georges wrote: > I see... So I guess the question is not "Why does ML treat the second > argument as a string or as a regex sometimes?" The second argument is > always a string, which must be a valid lexical regular expression. > > But would rather be: "Do you confirm ML has a limitation on the length of > a regex, which appears to be 1463 characters?" > > And of course: "Why?" Good question indeed... > > -- > Florent Georges > http://fgeorges.org/ > http://h2oconsulting.be/ > > > On 22 August 2016 at 13:27, Johan de Boer wrote: > >> All, >> >> >> I have simplified my example in the XQuery Console to: >> >> >> let $string1 := "aaaa" >> let $string2 := "bbbb" >> let $length-1 := 1463 >> let $length-2 := 1464 >> let $string3 := >> fn:string-join >> (for $a in 1 to $length-1 >> return 'x') >> return fn:replace($string1,$string3,$string2) >> >> Now using the length of 1463 it works fine. It is seen as a string a that >> is what I want. But incremented the length by only 1 to 1464 (so replacing >> $length-1 by $length-2 in the above example) I got the error: >> XDMP-REGEX: (err:FORX0002) fn:replace("aaaa", >> "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...", >> "bbbb") -- Invalid regular expression But I just want that Marklogic >> also treats the the string of length 1464 as a string and not as regular >> expression. So the question is: >> >> Why does MarkLogic treat a second argument in fn:replace as a string when >> it has length 1463 (or less) and why does it treat it as a regular >> expression when it has length 1464 (or more)? >> >> It is not about the usefulness of the above example. It is about why the >> error appears. This example is just a simplifying of a situation which >> happens in a production environment. >> >> >> Regards, >> >> >> Johan >> >> <http://www.tahzoo.com> >> Johan de Boer >> Developer Java / Developer MarkLogic >> P: *0031 88 268 2500* <0031%2088%20268%202500> | M: >> *0031 6 444 22 758* <0031%206%20444%2022%20758> >> E: *[email protected]* <[email protected]> | W: >> *www.tahzoo.com* <http://www.tahzoo.com> >> A: *Delftechpark 37I , 2628 XJ Delft, Netherlands* >> <https://www.google.com/maps/place/Delftechpark+37,+2628+XJ+Delft,+Netherlands/@51.997531,4.3824845,17z/data=!3m1!4b1!4m5!3m4!1s0x47c5b589ec2c237b:0x22b6e5d15befb3d5!8m2!3d51.997531!4d4.3846732> >> >> ------------------------------ >> *From:* [email protected] < >> [email protected]> on behalf of Florent Georges < >> [email protected]> >> *Sent:* Monday, August 22, 2016 1:10:27 PM >> *To:* MarkLogic Developer Discussion >> *Subject:* Re: [MarkLogic Dev General] Why does fn:replace gives an >> error when second argument exceeds certain length >> >> Hi, >> >> Not sure about the details of the length (it's hard to look at a >> non-reduced example containing a lot of noise), but you pass $piece-of-xml >> (or at least a substring of it) as a regex to fn:replace(). >> >> So MarkLogic tells you it's not a valid regex, and it looks right to do >> so. >> >> It's not clear what you want to replace in "aaaa" using the literal XML >> as a regex. >> >> Regards, >> >> -- >> Florent Georges >> http://fgeorges.org/ >> http://h2oconsulting.be/ >> >> >> On 22 August 2016 at 12:03, Johan de Boer wrote: >> >>> I am using MarkLogic release 8.0-4 and I get a problem with fn:replace >>> if the second argument exceeds a certain length. I use the following script >>> in XQuery. This is just a simple query with the only goal to show the error. >>> >>> >>> let $string1 := "aaaa" >>> let $string2 := "bbbb" >>> let $length-1 := 1463 >>> let $length-2 := 1464 >>> let $piece-of-xml := '<change when="2015-01-21" >>> status="created"/><change when="2015-09-16" who="9999999999999999999">ABCD >>> EF G</change><change when="2015-09-17" who="9999999999999999999">ABCD EF >>> G</change><change when="2015-09-22" who="999999999999999999">ABCD EF >>> GH</change><change when="2015-10-09" who="9999999999999999999">ABCD EF >>> G</change><change when="2016-04-01" who="9999999999999999999">Abcd >>> Abcdefgh</change><change when="2016-04-02" who="9999999999999999999">Abcd >>> Abcdefgh</change><change when="2016-04-06" who="999999999999999999">ABCD EF >>> GH</change><change when="2016-04-09" who="9999999999999999999">Abcd >>> Abcdefgh</change><change when="2016-04-10" who="9999999999999999999">Abcd >>> Abcdefgh</change><change when="2016-04-18" who="9999999999999999999">Abcd >>> Abcdef</change><change when="2016-04-22" who="9999999999999999999">Abcd >>> Abcdefgh</change><change when="2016-04-23" who="9999999999999999999">Abcd >>> Abcdefgh</change><change when="2016-06-26" who="9999999999999999999">Abcd >>> Abcdefgh</change><change when="2016-06-27" who="9999999999999999999">Abcdef >>> Abcdefghijk</change><change when="2016-06-28" >>> who="9999999999999999999">Abcdef >>> Abcdefghijk</change><change when="2016-07-01" >>> who="9999999999999999999">Abcd Abcdefgh</change><change when="2016-07-02" >>> who="9999999999999999999">Abcd Abcdefgh</change><change when="2016-07-02" >>> who="9999999999999999999">Abcdef Abcdefghijk</change><change >>> when="2016-07-03" who="9999999999999999999">Abcd Abcdefgh</change><change >>> when="2016-07-03" who="9999999999999999999">Abcdef >>> Abcdefghijk</change></listChange>' >>> let $test1 := fn:substring($piece-of-xml,1,$length-1) >>> return fn:replace($string1,$test1,$string2) >>> >>> This returns the expected value 'aaaa'. >>> >>> But when I increase the selected length by 1 by replacing: >>> >>> let $test1 := fn:substring($piece-of-xml,1,$length-1) >>> >>> by >>> >>> let $test1 := fn:substring($piece-of-xml,1,$length-2) >>> >>> I get the error: >>> XDMP-REGEX: (err:FORX0002) fn:replace("aaaa", "<change >>> when="2015-01-21" status="created"/>...", "bbbb") >>> -- Invalid regular expression The value of $test1 at that point is: >>> >>> <change when="2015-01-21" status="created"/><change when="2015-09-16" >>> who="9999999999999999999">ABCD EF G</change><change when="2015-09-17" >>> who="9999999999999999999">ABCD EF G</change><change when="2015-09-22" >>> who="999999999999999999">ABCD EF GH</change><change when="2015-10-09" >>> who="9999999999999999999">ABCD EF G</change><change when="2016-04-01" >>> who="9999999999999999999">Abcd Abcdefgh</change><change when="2016-04-02" >>> who="9999999999999999999">Abcd Abcdefgh</change><change when="2016-04-06" >>> who="999999999999999999">ABCD EF GH</change><change when="2016-04-09" >>> who="9999999999999999999">Abcd Abcdefgh</change><change when="2016-04-10" >>> who="9999999999999999999">Abcd Abcdefgh</change><change when="2016-04-18" >>> who="9999999999999999999">Abcd Abcdef</change><change when="2016-04-22" >>> who="9999999999999999999">Abcd Abcdefgh</change><change when="2016-04-23" >>> who="9999999999999999999">Abcd Abcdefgh</change><change when="2016-06-26" >>> who="9999999999999999999">Abcd Abcdefgh</change><change when="2016-06-27" >>> who="9999999999999999999">Abcdef Abcdefghijk</change><change >>> when="2016-06-28" who="9999999999999999999">Abcdef >>> Abcdefghijk</change><change when="2016-07-01" >>> who="9999999999999999999">Abcd Abcdefgh</change><change when="2016-07-02" >>> who="9999999999999999999">Abcd Abcdefgh</change><change when="2016-07-02" >>> who="9999999999999999999">Abcdef Abcdefghijk</change><change >>> when="2016-07-03" who="9999999999999999999">Abcd Abcdefgh</change><change >>> when="2016-07 >>> >>> Why do I get this error in MarkLogic? >>> >>> >>> >>> <http://www.tahzoo.com> >>> Johan de Boer >>> Developer Java / Developer MarkLogic >>> P: *0031 88 268 2500* <0031%2088%20268%202500> | M: >>> *0031 6 444 22 758* <0031%206%20444%2022%20758> >>> E: *[email protected]* <[email protected]> | W: >>> *www.tahzoo.com* <http://www.tahzoo.com> >>> A: *Delftechpark 37I , 2628 XJ Delft, Netherlands* >>> <https://www.google.com/maps/place/Delftechpark+37,+2628+XJ+Delft,+Netherlands/@51.997531,4.3824845,17z/data=!3m1!4b1!4m5!3m4!1s0x47c5b589ec2c237b:0x22b6e5d15befb3d5!8m2!3d51.997531!4d4.3846732> >>> >>> >>> _______________________________________________ >>> 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 >> >> > > > >
_______________________________________________ General mailing list [email protected] Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general
