Splitting a String with a Delimiter That is Present in the String Itself

I’m sorry for the confusing title, but the issue I am facing will become evident as yo read on.

I have a block of string in the form of “Option1, Option2, Option3…”
Splitting this is easy, with StrVariable.Split(","c)

But some of the options may contain the delimiter itself:
“Option1, Option2, Option3…Optio,n10, Op,tion11

Help would be most appreciated.
Thanks in Advance!

Kind Regards,
Ashwin A.K

the sample values are very general and maybe the approach needs to be shifted more on the details. Maybe the comma can be detected and removed with the help of regex.
grafik
here the comma is identified if it stands between 2 small case letters

Hi @ppr,

Thank you for your response, I will add more details to my query.

I wish to separate the values as they are, i.e., when I split them into an array, the items should be {“Option1”, “Option2”, “Option3”…“Optio,n10”, “Op,tion11”}.

Here are is an example of the actual string(just a portion of it that contains two items)
“All Indirect.Employee Bonuses, Awards and Incentives,
OPS Catalog Only.Employee Bonuses, Awards and Incentives”

Writing it down once more, highlighting the commas present inside of the items themselves:
“All Indirect.Employee Bonuses, Awards and Incentives, OPS Catalog Only.Employee Bonuses, Awards and Incentives”

As you can see, I won’t be able to split them into two items, it will come back as four items.

I only wish to retain those commas that come before “All Indirect.” and “OPS Catalog”
From your description above, this is the expression I came up with, but I’ve screwed up somewhere.

,(?=[(All Indirect.)|(OPS Catalog)])

Kind Regards
Ashwin A.K

in that case you are close bound to the values, maybe this would work:


grafik

1 Like

It helped @ppr,
Thank you so much!

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