xsl-list
[Top] [All Lists]

Re: [xsl] tokenizing comma separated string with quotes

2007-02-22 06:10:56
On 2/22/07, Abel Braaksma <abel(_dot_)online(_at_)xs4all(_dot_)nl> 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.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--