LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to split a string into an array but skip splitting if a character is present

Solved!
Go to solution

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 

0 Kudos
Message 1 of 7
(3,907 Views)

@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:

  • []     An empty string
  • A string of ,,,,,,,,,, commas
  • A string ((of (nested) groups))
  • A string ((of mis-nested groups)
  • Another (mis-nested example))
  • One more () interesting nest

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

0 Kudos
Message 2 of 7
(3,887 Views)

To be clearer, here is my input and the output I need.

Can you help me with to achieve that, practicatly? 

thanks

 

0 Kudos
Message 3 of 7
(3,877 Views)

What code do you have so far, and can you attach it?

0 Kudos
Message 4 of 7
(3,866 Views)
Solution
Accepted by sHrG78

This seems to work.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 5 of 7
(3,863 Views)

You may have just done sHrG78's homework assignment...

0 Kudos
Message 6 of 7
(3,859 Views)

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.

0 Kudos
Message 7 of 7
(3,842 Views)