Identify first n characters of regex pattern : I'm trying to mask all the occurences of **AccountNumber** in my XML response code. The AccountNumber has 16 digits and I want to mask first 12 digits and retain last four.

XML response:

    <ns2:PaymentMethod>
      <CCInfo xmlns="">
               <AccountType>sdaj</AccountType>
               <AccountNumber>1234567890123456</AccountNumber>
               <AccountName>sdfsad</AccountName>
               <ExpirationMonth>sdaf</ExpirationMonth>
               <ExpirationYear>afgds</ExpirationYear>
        </CCInfo>
      </ns2:PaymentMethod>
      <ns2:PaymentMethod>
      <CCInfo xmlns="">
               <AccountType>kyfkuk</AccountType>
               <AccountNumber>098765432123987</AccountNumber>
               <AccountName>hjvkv</AccountName>
               <ExpirationMonth>gfdgh</ExpirationMonth>
               <ExpirationYear>tdjk</ExpirationYear>
        </CCInfo>
      </ns2:PaymentMethod>

Below is my java code:

    String accountNumberPatternString ="<AccountNumber>(^.{12})";
	Pattern accountNumberPattern = Pattern.compile(accountNumberPatternString);
    Matcher matcher = accountNumberPattern.matcher(data);
	String maskedResult = matcher.replaceAll("<AccountNumber>*******");

I'm expecting the result as:

    <AccountNumber>************3456</AccountNumber>

but I'm getting the result as:

    <AccountNumber>1234567890123456</AccountNumber>