- From: Michael Kay <mike@saxonica.com>
 - Date: Thu, 3 Dec 2020 07:19:07 +0000
 - To: public-xslt-40@w3.org
 - Message-Id: <142D6993-9BF7-4607-A020-D2FC880A75AE@saxonica.com>
 
Dimitre's concerns about the naming of the proposed replace-with() function could also be addressed by combining replace() and replace-with() into a single new fn:replace#2 using keyword parameters:
replace($input, pattern:="[0-9]+", replacement:="#$0")
replace($input, pattern:="[0-9]+", replacement:="#$0", flags="ms")
replace($input, pattern:="[0-9]+", using:=format-integer(?, 'Ww'))
which might open the door to having a replacement function with access to matched subgroups:
replace($input, pattern:="^([0-9]+)/([0-9]+)/([0-9]+)$", process-groups="map{
   1: format-integer(?, '00'),
   2: map{'1': 'January', '2': 'February', ...}
   3: format-integer(?, '0000')
})
(the value of process-groups is a function that accepts a group number as input and returns a function used for processing that group; in this example we exploit the fact that a map is a function).
Michael Kay
Saxonica
Received on Thursday, 3 December 2020 07:19:26 UTC