[
https://issues.apache.org/jira/browse/JENA-740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14052894#comment-14052894
]
ASF subversion and git services commented on JENA-740:
------------------------------------------------------
Commit 1608039 from [~andy.seaborne] in branch 'jena/trunk'
[ https://svn.apache.org/r1608039 ]
JENA-740 : REPLACE to handle empty string consistently
> SPARQL replace
> --------------
>
> Key: JENA-740
> URL: https://issues.apache.org/jira/browse/JENA-740
> Project: Apache Jena
> Issue Type: Improvement
> Components: ARQ
> Affects Versions: Jena 2.11.2
> Reporter: Andy Seaborne
> Priority: Minor
>
> [users@ email report "Replace doesn't error on patterns that match zero
> length
> strings"|http://mail-archives.apache.org/mod_mbox/jena-users/201407.mbox/%3CCA%2BQ4Jn%3DqOS85yCPGexqX%2BLFkX4Dw8QSQmBLq2kT05%2Btvj0xksA%40mail.gmail.com%3E].
> {{replace("abc", ".*", "x")}} returns {{"xx"}} because it uses Java's
> Matcher.replaceAll - it's one match for the whole of "abc" (it's a greedy
> pattern) and one match for the trailing empty string. Java returns {{"x"}}
> for an empty string, and {{"xx"}} for any non-empty string in place of "abc".
> F&O calls out this case and makes it an error.
> http://www.w3.org/TR/xpath-functions/#func-replace
> {quote}
> An error is raised \[err:FORX0003\] if the pattern matches a zero-length
> string, that is, if the expression fn:matches("", $pattern, $flags) returns
> true. It is not an error, however, if a captured substring is zero-length.
> {quote}
--
This message was sent by Atlassian JIRA
(v6.2#6252)