Subject: Re: [xsl] Quoting meta characters for a regular expression character class From: Martin Honnen <Martin.Honnen@xxxxxx> Date: Mon, 25 Aug 2008 19:24:24 +0200 |
I currently am using XSL 2.0 and have a template that basically looks like:
<xsl:template name="chopPunctuation" as="xsd:string"> <xsl:param
name="chopString" as="xsd:string" required=yes" /> <xsl:param
name="punctuation" as="xsd:string" required="no"
select="string('.:,;/ ')" /> <xsl:variable name="rePattern"
as="xsd:string" select="concat('[',$punctuation,']+$')" /> <xsl:value-of select="replace($chopString,$rePattern,'')" /> </xsl:template>
Basically the template accepts a string and a list of characters to remove from the end of the string. The problem here is that I know I just cannot drop $punctuation into the created on-the-fly regular expression $rePattern since I have to account for any meta characters that $punctuation might have. I'm sure someone has come across this issue and has a function that will quote the necessary meta characters for a regular expression character class. Seems like this should be part of the standard XPath 2.0 functions to hide the details of regular expressions. After all Perl has had quotemeta() for quite some time...
Martin Honnen http://JavaScript.FAQTs.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Quoting meta characters for a, Houghton,Andrew | Thread | Re: [xsl] Quoting meta characters f, Dimitre Novatchev |
[xsl] Quoting meta characters for a, Houghton,Andrew | Date | [xsl] [ANN] New! Hands-on Schematro, B Tommie Usdin |
Month |