Skip to content

Instantly share code, notes, and snippets.

@princeppy
Last active November 29, 2024 14:38
Show Gist options
  • Select an option

  • Save princeppy/2c1e511d22b9a377cce41b1e1b6cf4ac to your computer and use it in GitHub Desktop.

Select an option

Save princeppy/2c1e511d22b9a377cce41b1e1b6cf4ac to your computer and use it in GitHub Desktop.

Revisions

  1. princeppy revised this gist Nov 29, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion dd-MMM-yyyy Regex.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    ^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]|(?:Jan|Mar|May|Jul|Aug|Oct|Dec)))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2]|(?:Jan|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)(?:0?2|(?:Feb))\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9]|(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep))|(?:1[0-2]|(?:Oct|Nov|Dec)))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$
    ```

    ![Regular expression visualization]([https://www.debuggex.com/i/oHKz49tAP49Cy42-.png](https://i.sstatic.net/D4YDF.png))
    ![Regular expression visualization](https://i.sstatic.net/D4YDF.png)

    [Debuggex Date Formatter](https://www.debuggex.com/r/A-JugmUS0sCbSQqo)

  2. princeppy revised this gist Nov 29, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion dd-MMM-yyyy Regex.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    ^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]|(?:Jan|Mar|May|Jul|Aug|Oct|Dec)))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2]|(?:Jan|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)(?:0?2|(?:Feb))\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9]|(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep))|(?:1[0-2]|(?:Oct|Nov|Dec)))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$
    ```

    ![Regular expression visualization](https://www.debuggex.com/i/oHKz49tAP49Cy42-.png)
    ![Regular expression visualization]([https://www.debuggex.com/i/oHKz49tAP49Cy42-.png](https://i.sstatic.net/D4YDF.png))

    [Debuggex Date Formatter](https://www.debuggex.com/r/A-JugmUS0sCbSQqo)

  3. princeppy revised this gist Nov 29, 2024. 2 changed files with 22 additions and 8 deletions.
    8 changes: 0 additions & 8 deletions dd-MMM-yyyy Regex
    Original file line number Diff line number Diff line change
    @@ -1,8 +0,0 @@
    ```
    ^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]|(?:Jan|Mar|May|Jul|Aug|Oct|Dec)))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2]|(?:Jan|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)(?:0?2|(?:Feb))\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9]|(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep))|(?:1[0-2]|(?:Oct|Nov|Dec)))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$
    ```

    https://regexr.com/39tr1

    https://stackoverflow.com/questions/15491894/regex-to-validate-date-formats-dd-mm-yyyy-dd-mm-yyyy-dd-mm-yyyy-dd-mmm-yyyy

    22 changes: 22 additions & 0 deletions dd-MMM-yyyy Regex.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    [Debuggex](https://www.debuggex.com)

    ```
    ^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]|(?:Jan|Mar|May|Jul|Aug|Oct|Dec)))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2]|(?:Jan|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)(?:0?2|(?:Feb))\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9]|(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep))|(?:1[0-2]|(?:Oct|Nov|Dec)))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$
    ```

    ![Regular expression visualization](https://www.debuggex.com/i/oHKz49tAP49Cy42-.png)

    [Debuggex Date Formatter](https://www.debuggex.com/r/A-JugmUS0sCbSQqo)

    ```py
    import re
    regex = re.compile("^(?:(?:31(/|\\-|\\.)(?:0{0,1}[13578]|1[02]|(?:Jan|Mar|May|Jul|Aug|Oct|Dec)))\\1|(?:(?:29|30)(/|\\-|\\.)(?:0{0,1}[1,3-9]|1[0-2]|(?:Jan|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))\\2))(?:(?:1[6-9]|[2-9]\\d){0,1}\\d{2,2})$|^(?:29(/|\\-|\\.)(?:0{0,1}2|(?:Feb))\\3(?:(?:(?:1[6-9]|[2-9]\\d){0,1}(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0{0,1}[1-9]|1\\d|2[0-8])(/|\\-|\\.)(?:(?:0{0,1}[1-9]|(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep))|(?:1[0-2]|(?:Oct|Nov|Dec)))\\4(?:(?:1[6-9]|[2-9]\\d){0,1}\\d{2,2})$")
    testString = "" # fill this in
    matchArray = regex.findall(testString)
    # the matchArray variable contains the list of matches
    ```

    https://regexr.com/39tr1

    https://stackoverflow.com/questions/15491894/regex-to-validate-date-formats-dd-mm-yyyy-dd-mm-yyyy-dd-mm-yyyy-dd-mmm-yyyy

  4. princeppy created this gist Aug 16, 2023.
    8 changes: 8 additions & 0 deletions dd-MMM-yyyy Regex
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    ```
    ^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]|(?:Jan|Mar|May|Jul|Aug|Oct|Dec)))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2]|(?:Jan|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)(?:0?2|(?:Feb))\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9]|(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep))|(?:1[0-2]|(?:Oct|Nov|Dec)))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$
    ```

    https://regexr.com/39tr1

    https://stackoverflow.com/questions/15491894/regex-to-validate-date-formats-dd-mm-yyyy-dd-mm-yyyy-dd-mm-yyyy-dd-mmm-yyyy