Blue Prism工具中Excel来源日期(dd/mm/yyyy格式)验证问题求助
Got it, let's work through this date validation issue you're hitting with Excel dates in Blue Prism. The problem with your original regex is that it forces two digits for day and month, but Excel often spits out single-digit days/months without leading zeros. Here's how to fix this:
Updated Regex Pattern
Use this regex to match dates with 1 or 2 digits for day/month and a 4-digit year:
^(0?[1-9]|[12][0-9]|3[01])/(0?[1-9]|1[012])/[0-9]{4}$
Let me break down the key parts:
0?[1-9]: Matches single-digit days/months (1-9) with or without a leading zero (e.g.,5or05)[12][0-9]: Covers days 10-293[01]: Handles valid end-of-month days (30 or 31)0?[1-9]|1[012]: Ensures months are 1-9 (with/without zero) or 10/11/12[0-9]{4}: Guarantees a 4-digit year (no 2-digit shortcuts like24)
Implementing This in Blue Prism
- Add a Regex Match action to your Blue Prism process.
- Paste the regex pattern above into the "Pattern" field.
- Feed your Excel-sourced date string into the "Input String" field.
- Check the "Match Result" output—if it returns
True, the date format fits yourdd/mm/yyyyrequirement (with or without leading zeros for single-digit values).
Bonus: Strict Date Validation (Beyond Regex)
Regex checks format, but it can’t catch invalid dates like 31/04/2024 (April only has 30 days) or 29/02/2023 (not a leap year). For full robustness, combine regex with Blue Prism’s date conversion function:
- After passing the regex check, use the
ToDate()function:ToDate([Your Date String], "dd/MM/yyyy") - If this function returns a valid date value, the date is both formatted correctly and logically valid. If it throws an error, mark the date as invalid.
This approach handles all the edge cases from Excel’s date formatting while keeping your validation solid in Blue Prism.
内容的提问来源于stack exchange,提问作者Ankhush singh

