Subject: Re: [xsl] analyze-string regex From: Liam R E Quin <liam@xxxxxx> Date: Thu, 27 Mar 2014 15:19:36 -0400 |
On Thu, 2014-03-27 at 17:06 +0000, Rushforth, Peter wrote: [...] > What I came up seems to work ok: > > <xsl:function name="ex:locationJson2Options"> > <xsl:param name="json"/><!-- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 --> > <xsl:variable name="regexps" select="'(\{.*?("title":.*?"(.*?)").*?("qualifier":.*?"(.*?)").*?("type":.*?"(.*?)").*?(((("bbox":.*?\[(.*?)\]).*?("geometry":.*?(\{.*?\})).*?\}{1,}))|(("geometry":.*?(\{.*?\})).*?\}{1,})))'"/> > <xsl:analyze-string select="$json" regex="{$regexps}" flags="s"> [...] > I am glad it didn't lead to madness, [...] It's subject to debate :-) For example, "title" : "The \"liteness\" of Bering: a sales qualifier" will probably fail.; that may or may not matter for you. One way to deal with \ would be to replace \" with some unicode string that you first checked didn't appear, and then your expression (modulo putting \s in there instead of .* in places) would be simpler. I'd also note you use " a lot, so change them to " and use '....' and ' instead. You can also build up a complex expression by making smaller variables (with comments) and using concat() at the end. Liam -- Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/ Pictures from old books: http://fromoldbooks.org/ Ankh: irc.sorcery.net irc.gnome.org freenode/#xml
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] analyze-string regex, Rushforth, Peter | Thread | Re: [xsl] analyze-string regex, Tony Graham |
Re: [xsl] XSLT Hello World - outrea, Ihe Onwuka | Date | Re: [xsl] XSLT compact syntax(es) [, Tony Graham |
Month |