Regex Date help

Hi @A_Learner

For “May 25, 2023” format:

[A-Za-z]+ \d{1,2}, \d{4}

For “02/04/2024” or “03/02/2024” format:

\d{2}/\d{2}/\d{4}

Regards,

Hi @A_Learner

\b(?:\d{1,2}/\d{1,2}/\d{4}|[A-Za-z]{3,9} \d{1,2}, \d{4})\b

Hope it helps!

Thank you @pravallikapaluri
Is there a way to avoid getting Next open date.

Thanks again

@A_Learner

(\w+ \d{1,2}, \d{4})|(\d{2}/\d{2}/\d{4})

1 Like

@A_Learner

Please find the below regex expression

([A-Z]+[a-z]+\s?\d+\,?\s+\d+)|(\d+\/\d+\/\d+)

Hope it works!!

Hey @A_Learner,

Here is a generic date regex,
((January|February|March|April|May|June|July|August|September|October|November|December) \d*, \d{4})|(\d{2}/\d{2}/\d{4})

@A_Learner

You can use the below regex if you want to avoid the open date

([A-Z]+[a-z]+\s?\d+\,?\s+\d+)|(\d{2}\/\d+\/\d+)

Regards

1 Like

@A_Learner

Thank You

Happy Automation !!

Thank you @vrdabberu

Thank you, every one for the education on Regex.

If Possible, can you please explain a little bit about the regex before |
I get the second part okay. Many Thanks,

Some good sites are:

  1. https://regex101.com/ - To test regex patterns or create
  2. Regex Tutorial | Regular Expression - Javatpoint - To understand regex symbols

@A_Learner

I have been considering the month over there and in this case its may and in other case it might be some other month so that’s the reason I have given

[A-Z]+ this consider the capital letters and + indicates 1 or more alphabets
[a-z]+ this consider the small letters and + indicates 1 or more alphabets
\s+ this represents the space and here + represents 1 or more spaces can be there
\d+ this consider the digits and + indicates 1 or more digits
,? this represents the , and the ? mark represents that the character before the question mark
can be considered or not means it can be there or not there and ? represents 0 or 1 character
\s+ this represents the space and here + represents 1 or more spaces can be there
\d+ this consider the digits and + indicates 1 or more digits

Regards

Thank you for your time.

Thank you @Quenton_Wayne_Rebello

1 Like

I am trying look behind for this, that is match this date pattern only with Closing Date or Preview Date etc. It is not working. Can you help? Below is the regex I am trying to use.

(?<=Preview Date )([A-Z]+[a-z]+\s?\d+,?\s+\d+)|(\d{2}/\d+/\d+)

Thank you,

@A_Learner

It works for me please check once

@A_Learner

it will not work if you give a preview date over there.

(?<=Preview Date )([A-Z]+[a-z]+\s?\d+,?\s+\d+)|(\d{2}/\d+/\d+)

Please remove this (?<=Preview Date ) i haven’t included it in my regex code

just use this and don’t add anything

([A-Z]+[a-z]+\s?\d+\,?\s+\d+)|(\d{2}\/\d+\/\d+)

Regards

(?:Closing Date: )?(?:Preview Date )?((?:[A-Z][a-z]+\s\d{1,2},?\s\d{4})|(?:\d{2}\/\d{2}\/\d{4}))

Explanation of the regex pattern:

  1. (?:Closing Date: )?: This part is for the optional “Closing Date:” prefix.
  2. (?:Preview Date )?: This part is for the optional “Preview Date” prefix.
  3. (: Start of the capturing group.
  4. (?:[A-Z][a-z]+\s\d{1,2},?\s\d{4}): This part matches the date in the format “May 25, 2023”. It allows one uppercase letter, one or more lowercase letters, followed by one or two digits for the day, an optional comma, and four digits for the year.
  5. |: The vertical bar acts as an OR operator.
  6. (?:\d{2}\/\d{2}\/\d{4}): This part matches the date in the format “02/04/2024” or “03/02/2024”. It allows two digits for the month, two digits for the day, and four digits for the year.
  7. ): End of the capturing group.

The regex pattern captures the dates in the provided formats, whether they are “Closing Date:” or “Preview Date” and extracts them as groups. You can use this pattern in a programming language or tool that supports regular expressions, such as Python, JavaScript, or any other language that UiPath supports for text manipulation.

Thank you @SwathiPuli for your time in explaining!!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.