Hi,
I am trying to match
“Statement 06/06/2023” or “Statement Issued 06/06/2023”
But the following is failing to get “Statement Issued 06/06/2023”.
Can you help? Thank you,
(?<=Statement Issued|Statement)(\s?[A-Za-z]+\s?\d+,?\d+)|(\s?\d{1,2}/\d{1,2}/\d{2,4}|\s?\d{1,2}-[A-Za-z]±\d{2,4})"
Yoichi
(Yoichi)
July 24, 2023, 11:36pm
3
Hi,
According to your pattern, you want to match not only MM/dd/yyyy style but also MMMM/dd/yyyy style (such as July 25,2023) don’t you?
If so, the following pattern will work.
System.Text.RegularExpressions.Regex.Match(yourString,"(?<=Statement\s+(Issued\s+)?)(Jan(uary)?|Feb(ruary)?|Mar(ch)?|Apr(il)?|May|Jun(e)?|Jul(y)?|Aug(ust)?|Sep(tember)?|Oct(ober)?|Nov(ember)?|Dec(ember)?)\s?\d+,?\d+|(\d{1,2}/\d{1,2}/\d{2,4}|\d{1,2}-(Jan(uary)?|Feb(ruary)?|Mar(ch)?|Apr(il)?|May|Jun(e)?|Jul(y)?|Aug(ust)?|Sep(tember)?|Oct(ober)?|Nov(ember)?|Dec(ember)?)-\d{2,4})",System.Text.RegularExpressions.RegexOptions.IgnoreCase).Value
note: (your pattern is not good because [A-Za-z]+ matches “Issued”)
Regards,
1 Like
Thank you, @Yoichi . Understood what is the issue with my Regex. Also like the ignore case option.
1 Like
@Yoichi
I have a very similar pattern
(?<=(Due Date:?|Due By:?)\s?)(Jan(uary)?|Feb(ruary)?|Mar(ch)?|Apr(il)?|May|Jun(e)?|Jul(y)?|Aug(ust)?|Sep(tember)?|Oct(ober)?|Nov(ember)?|Dec(ember)?)\s?\d+,?\s?\d+|(\d{1,2}/\d{1,2}/\d{2,4}|\d{1,2}-(Jan(uary)?|Feb(ruary)?|Mar(ch)?|Apr(il)?|May|Jun(e)?|Jul(y)?|Aug(ust)?|Sep(tember)?|Oct(ober)?|Nov(ember)?|Dec(ember)?)-\d{2,4})
But this is matching Invoice Date: 20-Jun-23
Why is that? i have specified Due Date.
Thank you,
Yoichi
(Yoichi)
July 25, 2023, 3:14am
8
Hi,
It seems necessary to surround pattern by parenthesis just after positive lookbehind as the following.
(?<=(Due Date:?|Due By:?)\s?)((Jan(uary)?|Feb(ruary)?|Mar(ch)?|Apr(il)?|May|Jun(e)?|Jul(y)?|Aug(ust)?|Sep(tember)?|Oct(ober)?|Nov(ember)?|Dec(ember)?)\s?\d+,?\s?\d+|(\d{1,2}/\d{1,2}/\d{2,4}|\d{1,2}-(Jan(uary)?|Feb(ruary)?|Mar(ch)?|Apr(il)?|May|Jun(e)?|Jul(y)?|Aug(ust)?|Sep(tember)?|Oct(ober)?|Nov(ember)?|Dec(ember)?)-\d{2,4}))
And sorry but the above my expression should be as the following.
System.Text.RegularExpressions.Regex.Match(yourString,"(?<=Statement\s+(Issued\s+)?)((Jan(uary)?|Feb(ruary)?|Mar(ch)?|Apr(il)?|May|Jun(e)?|Jul(y)?|Aug(ust)?|Sep(tember)?|Oct(ober)?|Nov(ember)?|Dec(ember)?)\s?\d+,?\d+|(\d{1,2}/\d{1,2}/\d{2,4}|\d{1,2}-(Jan(uary)?|Feb(ruary)?|Mar(ch)?|Apr(il)?|May|Jun(e)?|Jul(y)?|Aug(ust)?|Sep(tember)?|Oct(ober)?|Nov(ember)?|Dec(ember)?)-\d{2,4}))",System.Text.RegularExpressions.RegexOptions.IgnoreCase).Value
Regards,
1 Like
Thank you!! Working good. @Yoichi
1 Like
system
(system)
Closed
July 28, 2023, 6:33pm
10
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.