This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 6148 - [FO] Requirement: string replace without regex
Summary: [FO] Requirement: string replace without regex
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Functions and Operators 3.0 (show other bugs)
Version: Recommendation
Hardware: PC Windows NT
: P2 enhancement
Target Milestone: ---
Assignee: Michael Kay
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-09 12:56 UTC by Michael Kay
Modified: 2009-10-12 22:33 UTC (History)
1 user (show)

See Also:


Attachments

Description Michael Kay 2008-10-09 12:56:28 UTC
There is a common requirement to perform simple string replacement (for example, replace all occurrences of "M. Kay" with "Michael Kay"). This is tricky to achieve using the replace() function because (a) the second argument is treated as a regular expression, which means that characters like "." have a special meaning, and (b) the characters "$" and "\" have a special meaning in the replacement string.

Some possible approaches to meeting this requirement are (a) a function to escape all metacharacters in a string (change "M. Kay" to "M\. Kay"), (b) a new function replace-strings(), (c) a new flag for use in the flags argument of replace().
Comment 1 Liam R E Quin 2009-02-24 22:22:33 UTC
Accepted at Austin face-to-face meeting; this will need an example in the
specification, and the WGs preferred "q" for "quote" rather than
"l" for "literal", partly because no "letter ell" clarification is
needed (easier to read in queries etc.) and partly by analogy with \Q
in some regexp libraries.

Comment 2 Michael Kay 2009-05-26 11:12:13 UTC
Text implementing this new feature has been added to the editor's draft of the F+O specification.
Comment 3 Michael Kay 2009-10-12 22:33:57 UTC
Since the functionality to meet this requirement is in the current editor's draft (new "q" flag), I am marking this as closed.