#StackBounty: #java #regex Regex to replace single quote with single quote twice if it is inside <xsl: or <XSL:

Bounty: 50

Regular Expression to replace ' with '' if it is inside <xsl: else ' should remain as it is.
Code Snippet:

public static void main(String[] args) {
        String replaceSingleQuoteInsideXsltCondition = "(<\s*?xsl\s*?:.*?=.*?)(')(.*?)(')(.*?>)";
        String dummyXSLT = "<p>Thank you for sending us <xsl:for-each select="catalog/cd[artist='Bob Dylan']"> " +
                "paper's to prove your <span class="highlight"><xsl:if test="D01 ='Y'">Income</xsl:if></span> <span class="highlight"><xsl:if test="D02 ='Y'"> and " +
                "</xsl:if></span><span class="highlight"><xsl:if test="D03 ='Y'">Citizenship and/or Identity</xsl:if></span>. " +
                "We need a little more information to finish your application. Addition of few words like 7 o'clock, employees' or employ's and child's and 'xyz and 'hello'</p>" +
                "contact number for inquiry = '478965152' and email id = 'pqr@xyz'" +
                "<xsl:template match="num[ . = 3 or . = 5]"/></xsl:stylesheet><xsl:if test="contains($search, 'Web Developer') and (contains($expSearch, 'Computer') or contains($expSearch, 'Information') or contains($expSearch, 'Web' ))">" +
                "<xsl:if test="((node/ABC!='') and (normalize-space(node/DEF)='') and (normalize-space(node/GHI)=''))"> just a dummy sample.</xsl:if>";
        System.out.println(dummyXSLT.replaceAll(replaceSingleQuoteInsideXsltCondition,  "$1''$3''$5"));
    }

Actual Result by Above Code:

<p>Thank you for sending us <xsl:for-each select="catalog/cd[artist=''Bob Dylan'']"> paper's to prove your <span class="highlight"><xsl:if test="D01 =''Y''">Income</xsl:if></span> <span class="highlight"><xsl:if test="D02 =''Y''"> and </xsl:if></span><span class="highlight"><xsl:if test="D03 =''Y''">Citizenship and/or Identity</xsl:if></span>. We need a little more information to finish your application. Addition of few words like 7 o'clock, employees' or employ's and child's and 'xyz and 'hello'</p>contact number for inquiry = '478965152' and email id = 'pqr@xyz'<xsl:template match="num[ . = 3 or . = 5]"/></xsl:stylesheet><xsl:if test="contains($search, ''Web Developer'') and (contains($expSearch, 'Computer') or contains($expSearch, 'Information') or contains($expSearch, 'Web' ))"><xsl:if test="((node/ABC!='''') and (normalize-space(node/DEF)='') and (normalize-space(node/GHI)=''))"> just a dummy sample.</xsl:if>

Expected Result:

<p>Thank you for sending us <xsl:for-each select="catalog/cd[artist=''Bob Dylan'']"> paper's to prove your <span class="highlight"><xsl:if test="D01 =''Y''">Income</xsl:if></span> <span class="highlight"><xsl:if test="D02 =''Y''"> and </xsl:if></span><span class="highlight"><xsl:if test="D03 =''Y''">Citizenship and/or Identity</xsl:if></span>. We need a little more information to finish your application. Addition of few words like 7 o'clock, employees' or employ's and child's and 'xyz and 'hello'</p>contact number for inquiry = '478965152' and email id = 'pqr@xyz'<xsl:template match="num[ . = 3 or . = 5]"/></xsl:stylesheet><xsl:if test="contains($search, ''Web Developer'') and (contains($expSearch, ''Computer'') or contains($expSearch, ''Information'') or contains($expSearch, ''Web'' ))"><xsl:if test="((node/ABC!='''') and (normalize-space(node/DEF)='''') and (normalize-space(node/GHI)=''''))"> just a dummy sample.</xsl:if>


Get this bounty!!!