Actions
Bug #3609
closedRegex capturing group ignored on .NET
Start date:
2018-01-10
Due date:
% Done:
100%
Estimated time:
Legacy ID:
Applies to branch:
9.8, trunk
Fix Committed on Branch:
9.8, trunk
Fixed in Maintenance Release:
Platforms:
Description
Reported by user:
regex problem in Saxon-HE 9.8.0.7N (and possibly other versions).
When using the native .NET regex engine (using the ";n" flag), capturing groups seem to be ignored.
Here is a style sheet that isolates the issue:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:variable name="input" select="'abc'"/>
<xsl:variable name="pattern" select="'a(.)c'"/>
<xsl:variable name="replacement" select="'x$1z'"/>
<xsl:template match="/">
<data>
<test><xsl:value-of select="replace($input, $pattern, $replacement)"/> (default)</test>
<test><xsl:value-of select="replace($input, $pattern, $replacement, ';j')"/> (Java)</test>
<test><xsl:value-of select="replace($input, $pattern, $replacement, ';n')"/> (.NET)</test>
</data>
</xsl:template>
</xsl:stylesheet>
When executed (on Windows 7, using ASP.NET or the Transform.exe tool) I get:
<data>
<test>xbz (default)</test>
<test>xbz (Java)</test>
<test>xz (.NET)</test>
</data>
The capturing group syntax should be valid on .NET as well:
There is, however, an option called ExplicitCapture that disables capturing with plain parentheses:
https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-options
I couldn't help noticing that this option is activated with a .NET specific flag "n".
Please register to edit this issue
Actions