- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 02:28 AM
Regex should mask if the card number is exactly 15 digits(including the first two) - not less than that not more than that
Here is the regex
var matches = testcases.match(new RegExp('(?:^|(?<=[^0-9]))37(?:[ \t-]*\\d){13}', 'gj'));
but the above is masking the number that has 16 digits as well.
Appreciate the Help
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 03:24 AM
Hi @SAS21,
Here is below code for the same.
var matches = testcases.match(new RegExp('(?:^|(?<=[^0-9]))37(?:[ \t-]*\\d){13}(?![0-9])', 'gj'));
Please accept my solution if it resolves your issue and thumps 👍 up
Thanks
Jitendra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 03:24 AM
Hi @SAS21,
Here is below code for the same.
var matches = testcases.match(new RegExp('(?:^|(?<=[^0-9]))37(?:[ \t-]*\\d){13}(?![0-9])', 'gj'));
Please accept my solution if it resolves your issue and thumps 👍 up
Thanks
Jitendra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 04:29 AM
Thank you Jitendra!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 04:01 AM
Hi @SAS21 ,
I tried your problem in my PDI and it works for me please check below code
var paragraph = '123456781234512';
var regex = /^(?=(?:\d\D*){1,15}$)\d+(?:[.,]\d+)?$/g;
var found = paragraph.match(regex);
gs.log("Fount = " + found);
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak