[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] Finding first difference between 2 text strings
Subject: Re: [xsl] Finding first difference between 2 text strings From: "James A. Robinson" <jim.robinson@xxxxxxxxxxxx> Date: Thu, 10 Sep 2009 20:41:21 -0700 |
> <xsl:function name="f:mismatch2" as="xs:integer?"> > <xsl:param name="a" as="xs:string" /> > <xsl:param name="b" as="xs:string" /> > <xsl:variable name="aa" select="translate($a,'.+*\{}[]','')"/> > <xsl:variable name="bb" select="translate($b,'.+*\{}[]','')"/> > <xsl:variable name="r" select="concat('^:',replace($bb,'.','($0'),replace($bb,'.',')?'),'.*')"/> > <xsl:sequence select="1+string-length(replace(concat(':',$aa),$r,'$1'))"/> > </xsl:function> Wow, that's... very very impressive. So you're replacing regular expression values with placeholders in both strings, then wrapping ever character in $bb with a regex expression, e.g., '(a)?', to finally perform a regex replacement on $aa? What does the leading colon do? Jim - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - James A. Robinson jim.robinson@xxxxxxxxxxxx Stanford University HighWire Press http://highwire.stanford.edu/ +1 650 7237294 (Work) +1 650 7259335 (Fax)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Finding first difference , David Carlisle | Thread | Re: [xsl] Finding first difference , David Carlisle |
Re: [xsl] Finding first difference , James A. Robinson | Date | Re: [xsl] Finding first difference , James A. Robinson |
Month |