I want to use a regex to grab, and remove, credit card numbers. I have found the following regex and tested it :
^(?:4[0-9]{12}(?:[0-9]{3})?|[25][1-7][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$
It matches correctly using a regex evaluator (eg www.regexr.com).
When I try to insert it into my code, it does not work :
var daRex = /^(?:4[0-9]{12}(?:[0-9]{3})?|[25][1-7][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/
daText = "Testing REGEX 123 4387000500875798";
daText = daText.replace(daRex, '');
Printing daText just shows the original text.
What have I done wrongly here ?
Thanks.