Split cell with multiple spaces

Hi
I am trying split a column of cells into two columns, however my data does not have specific delimiters. ie
Joe Blogs DeptA xxxx
Ian Smart DeptB xyxy

I need to split into 2 cells after the name and before the Dept

Any pointers would be welcome
Thanks

Hi @mgirdwood, can you tell us more about any patterns in your data to look for

e.g.

  • does the department always start with ā€œDeptā€?
  • is the name always two ā€œwordsā€?

Hello @mgirdwood
You can test with a ā€˜Regex Splitā€™ node with the following code:

(.+)(Dept.+) optionally (.+)((?i)Dept.+)

BR

2 Likes

Hi @takbb
Unofrtunately there can be more or less words for ā€œnameā€, the Department would always start with De

Not sure if that helps

Hello @mgirdwood
This is a simplification from above proposal:

(.+)((?i)De.+)

BR

2 Likes

@gonhaddock , I wonder if you might want to also ensure that De begins at a word boundary? putting (.+\b) in place of just (.+) - especially if case-insensitive.

@mgirdwood , unless you have a list of actual department names, itā€™s going to potentially be a bit ā€œhit and missā€.

What if you have:

Ivan Denisovich Department for Siberian Vacations

but without additional information on valid names, or valid departments Iā€™d say that what @gonhaddock has provided is the likely best solution

2 Likes

Thanks everyone for the excellent suggestions, with the data I have the regex from @gonhaddock seems to give me the outputs i need

2 Likes

Hello @takbb
I understand your concerns, my answer was generic to the challenge description.
However, the best way to ask in forum, is with a sharing sample of representative data, allowing us to scope the solution.

If the ā€˜Deā€™ always start with upper case, I would avoid the operator (?i).

(.+)(\bDe.+)

This can be a better approach for the time being.

Regards

PS. Great about ā€˜Ivan Denisovich Department for Siberian Vacationsā€™ :sweat_smile:,
in this case there wouldnā€™t be a problem as the code is greedy; but what about
ā€˜Ivan Denisovich Department for Denmark Vacationsā€™ (?)

2 Likes

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