573
Views
3
Comments
Solved
String_Split including empty space: " "
Question

I need to split a string that has the pattern: "10XX-11XX - ABCD - EFGH".


 Its necessary to keep in separeted values:

10XX-11XX

ABCD

EFGH


So, I'm using String_Split with the delimiter: " - "

It seems however that the delimiter that is being used is "-".


Anyone has had the same issue? How was solved?

Thanks in advance.



2016-04-22 00-29-45
Nuno Reis
 
MVP
Solution

String split works with a single character. If you write " - " it will split in either " " or "-". What is happening is that consecutive delimiters are interpreted as one so it seems it is spliting with "-" but the space are also disappearing.

The fastest way to go around it is replacing " - " by a single not used character like "#" and then split by "#".

String_Split(Replace(String," - ","#"),"#")
2021-05-25 20-26-04
Bernardo Condé

Hi,

As you have "-" and " - ", you can do a replace before to remove all spaces and then the string split, separating by "-".


Example:

1 - Replace (String, " ", "")
2 - String_Split (String, "-")


I hope to help

UserImage.jpg
Nuno Gomes
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.