Problem with regex
Added by Vladimir Nesterovsky about 6 years ago
Hello,
It seems I've found discrepancy in regex implementation during the transformation.
Consider the following xslt:
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:template match="/">
<xsl:variable name="text" as="xs:string"
select="'A = "a" OR B = "b"'"/>
<xsl:analyze-string regex=""(\\"|.)*?"" select="$text">
<xsl:matching-substring>
<xsl:message>
<xsl:sequence select="regex-group(0)"/>
</xsl:message>
</xsl:matching-substring>
</xsl:analyze-string>
</xsl:template>
</xsl:stylesheet>
vs javascript
<html>
<body>
<script>
var text = 'A = "a" OR B = "b"';
var regex = /"(\\"|.)*?"/;
var match = text.match(regex);
alert(match[0]);
</script>
</body>
</html>
xslt produces: "a" OR B = "b"
while javascript: "a"
Replies (2)
RE: Problem with regex - Added by Michael Kay about 6 years ago
Created W3C test case analyze-string-099
RE: Problem with regex - Added by Michael Kay about 6 years ago
Logged as a bug at https://saxonica.plan.io/issues/3902
Please register to reply