- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 05:24 AM - edited 05-29-2024 05:26 AM
Hi,
trying to check the pattern for the card data that has total 15 digits and always starts with eg: 27 . User can input the card data in any of the following formats (like with - or with space or without space ) 2755-051007-81973 or 2755 051007 81973 or 275505100781973. Have to look for these formats in the text field and print the message.
Was trying through the fix script with the sample text like below.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 05:30 AM
Hi @SAS21 ,
Try this code
var sampleText = " Work notes should not have sensitive information. Eg data formats are 2755-051007-81973 or 2755 051007 81973 or 275505100781973.";
var pattern = /27\d{2}[\-\s]?\d{6}[\-\s]?\d{5}/g;
var result = sampleText.match(pattern);
gs.info(result);
if(result) {
gs.info('sample text has card data');
}
I started answering community questions recently. If my answer helped you in any way, please mark it as helpful or correct. It would be a great boost.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 05:30 AM
Hi @SAS21 ,
Try this code
var sampleText = " Work notes should not have sensitive information. Eg data formats are 2755-051007-81973 or 2755 051007 81973 or 275505100781973.";
var pattern = /27\d{2}[\-\s]?\d{6}[\-\s]?\d{5}/g;
var result = sampleText.match(pattern);
gs.info(result);
if(result) {
gs.info('sample text has card data');
}
I started answering community questions recently. If my answer helped you in any way, please mark it as helpful or correct. It would be a great boost.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 06:57 AM
thank you sai. If we have to mask only the first 4 digits how can we implement that ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 04:08 AM
Hello Sai,
For Eg: if i have the data as follows , 27-5506-1006-81965. Is it possible to get the output as xx-xx06-1006-81956. Can we have the format of the data as it is and mask the 4 digits ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 04:12 AM
Have you tried the code in my previous response? I have provided the code to mask first 4 digits