Need Help in modifying the regex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 11:27 PM
Was trying to modify the following regex to accept the alphabets (caps and small) with/without spaces allowed at the front of the card number and at the back of the card number but its not working
Initial regex /\b27(?:[ \t-]*\d){13}\b/g; trying to modify this to accept the alphabets in case if the user enters by mistake an alphabet in front/at the end of the card number.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 11:48 PM
Will this work: /\b[A-Za-z\s]*27(?:[ \t-]*\d){13}[A-Za-z\s]*\b/g
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 01:17 AM
its working thank you...another question for the same sceanrio. is it possible to replace only the alphabet that is before the card number instead of replacing all the text
trying with this -match.replace(/[-\sA-Za-z]/g, '').replace(/^(\d{4})/, 'XXXX');
Input - Test Data A2765 071006 71992
with the above script its removing all the ( text) and giving o/p as XXXX07100671992
Required o/p should be Test Data AXXXX07100671992 . Is it possible to replace only the first alphabet if the card number has any before or end ?