xsl-list
[Top] [All Lists]

Re: [xsl] tokenizing comma separated string with quotes

2007-02-22 05:33:54
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


--~------------------------------------------------------------------
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>
--~--