07-27-2018 11:34 AM
Hello, I need to split a string into an array but skip the split if there is a parenthesis or quotation.
For example, if the string is "how,to,split,(bob,steave),string" and the comma is the condition to split, the output array will be: [how, to, split, (bob,steave), string]
I understand I need to set a condition but I'm not sure how to do it.
I have tried a few different approaches with no success.
I don't understand how to use scan string for tokens VI.
I appreciate the help
Solved! Go to Solution.
07-27-2018 12:37 PM
@sHrG78 wrote:
Hello, I need to split a string into an array but skip the split if there is a parenthesis or quotation.
For example, if the string is "how,to,split,(bob,steave),string" and the comma is the condition to split, the output array will be: [how, to, split, (bob,steave), string]
No, the output (with the single Rule you provided) would be "how", "to", "split", "(bob", "steave)", "string". You need to learn more about parsing and the notion of "special characters" (like "(" and ")", which I think you intend to mean "Everything contained herein is to be considered an "entire string", not to be split".
Here are some additional "sample" strings that you may want to consider when deciding on your "rules" and how you want to construct your parser:
One thing to build into your parser is the ability to say "You Violated the Rules, I Give Up" (a.k.a. an Error Condition).
Parsing is actually pretty well studied -- try it yourself, and if you are still stuck, consult the Web.
Bob Schor
07-27-2018 01:35 PM
To be clearer, here is my input and the output I need.
Can you help me with to achieve that, practicatly?
thanks
07-27-2018 02:18 PM
What code do you have so far, and can you attach it?
07-27-2018 02:21 PM
This seems to work.
07-27-2018 02:26 PM
You may have just done sHrG78's homework assignment...
07-27-2018 05:52 PM
I'm not a student. I wish they have taught me this tool in the engineering program I have finished not long ago.
I'm new in this tool and must complete some stuff ASAP at work.
Attached some of my attempts to tackle this issue.
Thanks for your time.