I am going to custom regex to find the credit card details from PDF using redact PDF activity.
Can you provide the Regex for USA credit card number , Exp Date & Special Code:
Example Value:
Cc # : 4400 1212 4955 7892
Exp Date: 07/24
Special Code : 087
1 Like
There is NO : pattern … We need to find the regex value using the value of each field
first pattern : (?<=: ).*
Second pattern : \d{4}\s\d{4}\s\d{4}\s\d{4}\s|\d{2}\W\d{2}|\d{3}
if its works mark solution
let me known if it doesn’t work
mkankatala
(Mahesh Kankatala)
April 1, 2024, 7:44am
5
Hi @Sathish_Kumar_S
You can try the below regular expressions to extract the required data,
For Credit card number -
(?<=Cc.*:\s)[\d\s]+
- Assign -> CCNumber = System.Text.RegularExpressions.Regex.Match(Input.toString, "(?<=Cc.*:\s)[\d\s]+").Value
For Exp Date -
(?<=Exp Date:\s)[\d\/]+
- Assign -> ExpDate = System.Text.RegularExpressions.Regex.Match(Input.toString, "(?<=Exp Date:\s)[\d\/]+").Value
For Special code -
(?<=Special Code\s?:\s)\d+
- Assign -> SpecialCode = System.Text.RegularExpressions.Regex.Match(Input.toString, "(?<=Special Code\s?:\s)\d+").Value
Hope it helps!!
Used this \d{4}\s\d{4}\s\d{4}\s\d{4}\s|\d{2}\W\d{2}|\d{3} pattern for redact and black color was applied to all the NUNBERS in the PDF .
Can we have a pattern based on the credit card value pattern & Exp date & Special code values instead of title of the each value?
Note : The activity does not redact phrases, sentences, or any group of words separated by a space, tab, or carriage
return. Regex patterns will match only contiguous words.
1 Like
check this for CC : (?<=Cc \W :\s)\d{4}\s\d{4}\s\d{4}\s\d{4}
if this work i will another one
check this pattern ::
(?<=Cc \W :\s)\d{4}\s\d{4}\s\d{4}\s\d{4} | (?<=Exp Date: )\d{2}\W\d{2}|(?<=Special Code : )\d{3}
let me known if its doesn’t work
if its work mark the solution
@jawagarraja123 the solution is not working… the regex is not finding the pattern and redact is not working
@jawagarraja123 the solution is not working… the regex is not finding the pattern and redact is not working…
can you provide all the value output value in text
after reading the pdf show me the output .
Actually , I was using the bot package ( [X-PDF Redaction - Example.zip) downloaded from below link to apply redaction function to hide the sensitive datas in input PDF file and store again in PDF
Updated 2/1/2021
I’m excited to announce a new custom activity to redact PDF Documents without the use of any third party software. The activity locates and irreversibly redacts confidential text to produce a fully redacted PDF document.
Watch a YouTube video of it in action: Custom Activity for PDF Redaction built for UiPath Studio - YouTube
Effective use cases are in GDPR compliance and adherence to data privacy laws.
[image]
Here’s are some example workflows illustrating the use of t…
I can’t share the data available in PDF as it is contain very sensitive data
Note : The input file which using in scanned PDF file
The below code help you get the value via regex
// Regular expression patterns (consider using named capturing groups for clarity)
const string creditCardNumberPattern = @"(?<cardNumber>\d{4} \d{4} \d{4} \d{4})";
const string expirationDatePattern = @"(?<expDate>(?:0[1-9]|1[0-2])\/\d{2})";
const string specialCodePattern = @"(?<specialCode>\d{3})";
Match cardNumberMatch = Regex.Match(text, creditCardNumberPattern);
Match expirationDateMatch = Regex.Match(text, expirationDatePattern);
Match specialCodeMatch = Regex.Match(text, specialCodePattern);
Credit Card Details Extraction from PDF Code explanation @Sathish_Kumar_S you can modify accouring to your rule and you can make this more dynamic
Component
Description
Text
String variable containing the PDF content. Replace "Your PDF text containing credit card details goes here"
with the actual text.
Regular Expressions
Patterns to match credit card number, expiration date, and special code.
CreditCardNumberPattern
@"(?<cardNumber>\d{4} \d{4} \d{4} \d{4})"
Named capturing group cardNumber
Captures the credit card number (XXXX XXXX XXXX XXXX) with spaces.
ExpirationDatePattern
`@"(?(?:0[1-9]
Named capturing group expDate
Captures expiration date in MM/YY format (two-digit year).
SpecialCodePattern
@"(?<specialCode>\d{3})"
Named capturing group specialCode
Captures special code as three digits.
Match and Extract
Use Regex.Match
to find patterns and access captured groups using Groups
property and the group names.
Redaction
Redact extracted credit card number immediately (e.g., replace digits with asterisks).
Validation (Optional)
Implement additional checks for extracted information (e.g., Luhn algorithm for credit card number).
Important Considerations:
This regex might not capture all valid credit card formats.
Always redact sensitive information promptly.
Consider using libraries specifically designed for credit card validation.