Masking credit card number
<p>What is the best way to mask credit card number in PHP?</p>

<p>The credit card number doesn't have to be valid.  So no need to do a Luhn Algorithm.  As long as it matches the pattern replace it with XXXXXXXX.</p>

<p>What I have so far:</p>

<pre><code>&lt;?php

$str = "The quick brown fox jumps over 5192696222257727 dog.";

$credit_card_re = '/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|622((12[6-9]|1[3-9][0-9])|([2-8][0-9][0-9])|(9(([0-1][0-9])|(2[0-5]))))[0-9]{10}|64[4-9][0-9]{13}|65[0-9]{14}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})*$/';
</code></pre>
