Split - alternative solution

How would you split a string with commas, containing commas!?

DIM arrVar(-1) as string arrVar = split(strVar, ",")

To send data to a Method, I use a string with commas… nothing special.

But in this new scenario, the text that will be send to the Method also may contain text with commas included!
What shall I do? Do I use other character such as # or the star, *? These could be replaced in the string , in both ends, so to speak.

Or, simply removed…!


My project evolves HTML, keywords and such and this information is the text for TITLE., DESCRIPTION and KEYWORDS people may write to a page or a site.
Simply, all characters, such as the # are used in these places or, can easily be removed. But commas are used and that could be a problem! :slight_smile:

What would you suggest?

You could use a non-printing character like chr(1) as a delimiter or move to something more structured like JSON or a even a class.

Hmm… Yes, why not!?
Ha!
I never thought of that!!
Silly, because that’s how the data is showing off in the first place…!!
Really silly!
Thank you!! :slight_smile:

0,0 : 1 1,0 : 1 2,0 : www.website.se 3,0 : 2016-06-14 4,0 : 5,0 : 6,0 : False 7,0 : 2016-06-21 8,0 : False 9,0 : [title] 10,0 : [description] 11,0 : [keywords] 12,0 : 323316433933120422

Comma separated is not very bright. I prefer Tab chr(9).

Well. Depending on the kind of information… Depending on if it’s me (i.e. the software) or the user that enter and send the information, comma may work.

But in this case, and other, the information is written by the user.
Would it be possible to use a combination!?

EndOfLine + chr(9)

I shall try to make an experiment… maybe it is possible to use!
I mean, what are the odds and the need to use both EndOfLine and TAB when enter a web based form??

I usually use these ASCII characters:
Chr(28) File Separator
Chr(29) Group Separator
Chr(30) Record Separator
Chr(31) Unit Separator

Indeed you can use combinations of characters as separator.

Just today I decide to use Tab;Tab to save a dictionary as separator between key and value where the keys may contain Tab.

I tend to use tab/char(9) were I would NEVER have a tab in the test. If the text might have any character then I use obscure text such as «FieldDivider» and «EOL».