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.