regex - some help needed with regular expression (xslt 2) -
i have next xml illustration :
<test> <p>some text (page 24)</p> <p>some text (page 24)</p> <p>there text here (page 24) , here (page 25)</p> <p>some text (pages 24, 7, 9)</p> </test>
and want utilize regex wrap page text snippets page_ref tag, result :
<test> <p>some text <page_ref>(page 24)</page_ref></p> <p>some text <page_ref>(page 24)</page_ref></p> <p>there text here <page_ref>(page 24)</page_ref> , here <page_ref>(page 25)</page_ref></p> <p>some text <page_ref>(pages 24, 7, 9)</page_ref></p> </test>
my code looks follows
<xsl:template match="text()"> <xsl:analyze-string select="." regex="\(([pp]age).*\)"> <xsl:matching-substring> <page_ref><xsl:value-of select="."/></page_ref> </xsl:matching-substring> <xsl:non-matching-substring> <xsl:value-of select="."/> </xsl:non-matching-substring> </xsl:analyze-string> </xsl:template>
but fails on 3d p tag, produces
<p>there text here <page_ref>(page 24) , here (page 25)</page_ref></p>
so if able point me error i'll happy guy. in advance !
you seek matching character except ), next ).
"\(([pp]age)[^)]*\)"
regex xslt-2.0
No comments:
Post a Comment