12-04-2019 10:47 AM
Hello,
I'm new to labview and I have a problem dividing my string into an array and removing the parts that don't fit me
The string is (including brackets):
[
"String1",
"String2",
"String3",
"",
"",
"",
"",
"",
]
}
in this case I need to extrapolate the words and put them in a new array. also I should be able to add all the words I want. in fact the quotation marks under the words means that there could be more words
Solved! Go to Solution.
12-04-2019 10:51 AM
Is that a single string or an array of strings? Can you post the VI you're working on?
As a side note: "Spreadsheet string to Array" is sometimes a good way to get an array of strings if that's what you need.
12-04-2019 10:55 AM
Hi Martin,
what are the rules to "split the string" into "words"?
Are there always brackets? Always square brackets? Only the closing curvy bracket, but no opening bracket?
Always commas between "words"? Also always linebreaks between "words" and commas? Which kind of linebreaks?
Any rule to decide which parts "don't fit you"?
Most/heaviest task of "programming" is to define rules (aka algorithms)…
12-04-2019 11:49 AM
It is always easiest for us of you would attach a simple VI that contains a typical string as a diagram constant (now we can see the delimiters, etc.). Then tell us what result you expect after processing.
Is the number of lines variable or fixed?
How can we possibly know what doesn't "fit you"? What are the rules for that? (e.g. skip empty strings? words that don't start with capital S? words with less than 3 characters? words not inside double-quotes? etc.)
12-04-2019 02:43 PM
This would get you started:
12-04-2019 03:34 PM
You can use a regular expression to solve a problem like this. Assuming you're only interested in strings between double quotes the following code will extract all the non-empty strings (you can add as many strings in double quotes as you want) . If you want to get the empty strings also just replace the "+" by a "*" in the regular expression.
Ben64
12-04-2019 03:36 PM
regular expressions are great. I really need to learn how to use them better.
12-05-2019 02:58 AM
Hi Ben,
it was just what I needed thanks !!!
you don't know how much time I've lost for it
kudos comiiing