This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
@NicoleJohnson Thank you - this worked. However, now I have a second question (refinement of the first question actually).
In the regex, to account for situations where I have multiple instances of a hypen surrounded by other characters, how would I adjust the regex so that it split on the 2nd hyphen? So as an example, in the below:
North-Technical Operations-Smith, John Joseph
your expression is correctly splitting on North. But is it possible to have it adjust to split into
North-Technical Operations and Smith, John Joseph
Also, could the count of hyphens RegEx be modified to look for hyphens surrounded by other characters only?
That will turn North-Technical Operations-Smith, John Joseph into North-Technical Operations|Smith, John Joseph, at which point you could use a Text to Columns tool to split the field on the pipe delimiter. I've attached a workflow with a bunch of examples that appear to work with this logic, including hyphens on either side of the split.
As for the count of matches, just add the \S on either side of the hyphen to get the count of only those scenarios that do not have whitespace surrounding the hyphen: REGEX_Countmatches([Field1],"(\S-\S)")
I believe it's because there isn't a space after Smith in the one that's failing? You will probably end up with a few exceptions regardless of the expression you choose... perhaps you can add a filter after this step to check for null values in the second column, and then you might need to apply different expression or manually review those exceptions.