RE: [xsl] Using parameter as regex in matches() function

Subject: RE: [xsl] Using parameter as regex in matches() function
From: "Houghton,Andrew" <houghtoa@xxxxxxxx>
Date: Thu, 29 May 2008 18:23:14 -0400
> From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
> Sent: Thursday, May 29, 2008 6:10 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: [xsl] Using parameter as regex in matches() function
>
> You want
>
> matches(., concat('^', $criteria_name, '$'))

Assuming that $criteria_name doesn't include any regular expression meta
characters.  Unfortunately, XSL doesn't have the Perl equivalent of
quotemeta() built into the library.  Certainly you can write a replace() to do
it and create a quotemeta() function to wrap it, but it would have been nice
to say:

matches(.,concat('^',quotemeta($criteria_name),'$'))


Andy.

Current Thread