You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Andy Seaborne (JIRA)" <ji...@apache.org> on 2014/07/04 12:58:33 UTC

[jira] [Updated] (JENA-740) SPARQL replace

     [ https://issues.apache.org/jira/browse/JENA-740?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andy Seaborne updated JENA-740:
-------------------------------

    Description: 
[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}


  was:
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}



> 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)