Re: [xsl] tokenizing comma separated string with quotes

Subject: Re: [xsl] tokenizing comma separated string with quotes
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Thu, 22 Feb 2007 13:31:54 +0100
Andrew Welch wrote:

I can translate away the quotes, but it would be nice if the regex could be modified to do the same thing.

(don't think this q. is from Andrew Welch, but anyway)


don't use translate when you are using XSLT 2.0 unless you use it for what it is supposed to be used for. You need more flexibility, use replace():

replace($input, ' ^"|"$" ', '', 'x')

which will remove opening/closing quotes. Use:

replace($input, ' " ', '', 'x')

to remove any quote (here you can use translate() as well). Use:

replace($input, ' ^([ " '' ])|\1$" ', '', 'x')

(remove spaces in the character class) if you want to remove quotes in:

"my text here" and 'my text here' but not in
"my text here' or 'my text here"

HTH, cheers,
-- Abel Braaksma

Current Thread