I'm trying to replace the first 12 digits of credit card numbers with X's in a predictable blob of text that contains the string:
Credit Card Number: 1234123412341234
Here's my PHP function:
preg_replace('/Credit Card Number: ([0-9]{12})/','Credit Card Number: XXXXXXXXXXXX',$str);
The problem is that the input string is not be affected.
Dumb question: you are assigning the returned value back to $str
right?
$str = preg_replace('/(Credit Card Number: [0-9]{12}/','Credit Card Number: XXXXXXXXXXXX',$str);