I am finding numbers more then two with comma but my regex find numbers inside or outside parentheses. How to find numbers not inside parentheses.
Regex used
([0-9]+, ){2,}
String
Albemarle Paper Co. v Moody (1975) 422 US 405, 425, 95 S Ct 2362
Expected Result
Albemarle Paper Co. v Moody (1975) 422 US 405, 95 S Ct 2362
In particular, my XML looks like
<root>
<p><styled-content><italic>Agarwal v Johnson </italic>(1979) 25 C3d 932, 942, overruled on *6 other grounds in <italic>White v Ultramar, Inc.</italic> (1999) 21 C4th 563</styled-content></p>
</root>
Here is the XSL template with the regex and replace function:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="root">
<xsl:copy>
<p><xsl:value-of select="replace(p/styled-content, '[0-9]+(?:, [-0-9]+)+,(?![^()]*\))', '')"/></p>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>