# Regex Split

**URL:** <https://forum.knime.com/t/regex-split/80308>\
**Category:** KNIME Analytics Platform\
**Tags:** regex\
**Created:** [June 11, 2024, 6:14pm UTC](https://forum.knime.com/t/regex-split/80308 "2024-06-11T18:14:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sergiogarciagt](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/s/e99b99/32.png) [@sergiogarciagt](https://forum.knime.com/u/sergiogarciagt)\
**Post date:** [June 11, 2024, 6:14pm UTC](https://forum.knime.com/t/regex-split/80308/1 "2024-06-11T18:14:59Z")

</div>

Hi, what would be the regex split I should use to get the date from this path?  
I modified the path for illustration purposes. I would like to have 01-31-2023. Thank you!

C:\Users\MESSI\OneDrive - Inter\Documents\Messi L\MIB\MIB-2022 for 2023\2023\Player Count\Player Count for Team Mgmt 01-31-2023.xlsx

---

<div class="post-metadata">

**Author:** ![MartinDDDD](https://forum-cdn.knime.com/user_avatar/forum.knime.com/martindddd/32/69988_2.png) [@MartinDDDD](https://forum.knime.com/u/MartinDDDD)\
**Post date:** [June 11, 2024, 6:48pm UTC](https://forum.knime.com/t/regex-split/80308/2 "2024-06-11T18:48:32Z")

</div>

> [@sergiogarciagt](#):
>
> C:\Users\MESSI\OneDrive - Inter\Documents\Messi L\MIB\MIB-2022 for 2023\2023\Player Count\Player Count for Team Mgmt 01-31-2023.xlsx

Regex to use in the Regex Split Node: (._?)(\d{2}-\d{2}-\d{4})(._?)

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/7/c/7c8692e34021324670493614c947245ed7a872f9.png)

Should result in this:

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/1/3/13edf3aa049e27e279b5d96d2c930c8c51770de8.png)

---

<div class="post-metadata">

**Author:** ![sergiogarciagt](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/s/e99b99/32.png) [@sergiogarciagt](https://forum.knime.com/u/sergiogarciagt)\
**Post date:** [June 11, 2024, 7:38pm UTC](https://forum.knime.com/t/regex-split/80308/3 "2024-06-11T19:38:51Z")

</div>

Thank you! @MartinDDDD this worked exactly how I was expecting. Do you mind share how the formula works, just for my general knowledge? thanks

---

<div class="post-metadata">

**Author:** ![MartinDDDD](https://forum-cdn.knime.com/user_avatar/forum.knime.com/martindddd/32/69988_2.png) [@MartinDDDD](https://forum.knime.com/u/MartinDDDD)\
**Post date:** [June 12, 2024, 6:49am UTC](https://forum.knime.com/t/regex-split/80308/4 "2024-06-12T06:49:52Z")

</div>

You’re welcome.

First of all I recommend [https://regex101.com/](https://regex101.com/) to test regex expressions.

What does the expression do:

- based on the structure of your path we expect three segments - before the date, the date, and after the date. That’s why the expression contains three subgroups ()()()
- the first and the last group use (.?): . means any character and ? means match that any character as many times (until you hit the next group) - that means the first (.?) selects everything until the date and the second (.?) everything after the date
- the middle group uses \d which matches any digit 0-9 followed by {2) which means, find any too consecutive digits. the “-” in-between means match a dash and at the end there’s another \d for digits with {4} to indicate 4 numbers are required.

Hope that makes sense.  
regex101 explains this probably a bit better (in the top right corner marked in red square):

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/1/1/113b2ce7e69d9a535a09a8cafd23754ecb8146b3.png)

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [June 19, 2024, 6:50am UTC](https://forum.knime.com/t/regex-split/80308/5 "2024-06-19T06:50:36Z")

</div>

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