String_Split-how to pass ","  a delimiter in string_split
Question
Application Type
Reactive

Hi Team ,

we have a requirement like the following

input stirng : "test1","test2", "test3,1,2,3".

And the output should be as

"test1"

"test2"

"test3,1,2,3"

is there a way to pass ( "," ) whole as a delimiter instead of single character ','.

Thanks

Srinivas Nalamati

mvp_badge
MVP

Hi Srinivas,

String_split is a very simple string splitter, you cannot do with it what you describe. Instead, I'd take a look at the various CSV-handling Forge components, as they can handle delimiters within quoted strings.

We use the CVS forge components ... they are similar to the ExcelToRecord list so it automatically puts all of your data in to a list structure for processing without having to parse it.

Hi Srinivas.

The thing you can do is previously replace all occurrences of your delimiter (",") by a single char, let's say '§'. And then do the split by that char. It's not risk free as this assumes the '§' char is not in your string.

mvp_badge
MVP

I'm not sure what good that would do?

As you said String_Split receives a set of chars to split the string. That is a simplistic way of turning a string delimiter in a char delimiter. Keeping in mind the mentioned risk involved.

Not a perfect solution, just a feasible solution.

mvp_badge
MVP

It's not a solution at all, unless I miss something. The problem the OP is having is that they have quote-delimited text that shouldn't be split, and I can't see how replacing all commas by something else could solve this.

Well, I understand the intention, replacing a sequence of double quote + comma + double quote into a single otherwise unused character and then do the StringSplit on that character.

But it´ s too simplistic.  You still have the first and last quote, and even in this simple example above, you can see it won´ t split between value 2 and 3 as there is an extra space between the comma and double quote.    

Dorine

Ah you are right! I misread Srinivas text. Though it could easily be fixed with: Replace(""",""", """§""").

Much similar to AJ solution which presents a better solution using Regex which addresses the extra nbsp character.

Hello Srinivas,

Here's one way -

1. Let's say the input string is "test1","test2" ,  "test3,1,2  ,3"  , "test 12 17"
2. First turn the input string into "test1"|"test2"|"test3,1,2  ,3"|"test 12 17"
(We replace all spaces before and after a comma to "|". You can choose to use any other character instead of the "|" character)3. Then I split the string on "|" into a list.

Attached is the oml for this logic and here are the results:

Hope this solves it,

AJ

StringSplit.oml

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