Re: [xsl] tokenizing comma separated string with quotes

Subject: Re: [xsl] tokenizing comma separated string with quotes
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Thu, 22 Feb 2007 13:10:26 +0000
On 2/22/07, Abel Braaksma <abel.online@xxxxxxxxx> wrote:
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)

er, it's from me :)



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

which will remove opening/closing quotes.

Cool, thanks. In csv quotes in quoted values are escaped by doubling the quotes, so just removing the opening/closing quotes is the way to go. (In my specific requirement though I can guarantee there's no escaped quotes so translate would've been fine)


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

It does, thanks Abel.


Current Thread