ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Count the \s between the comma

Solved!
Go to solution

Hello, I have a string as shown below, I need to count the \s between the comma. I found an example that counts the total of \s of the string, as shown. Can you help me?

 

image.pngimage.png

0 Kudos
Message 1 of 15
(4,271 Views)

Split string at first comma.  Find 2nd comma and split it there.

 

Now do the search for spaces on the part in between.

0 Kudos
Message 2 of 15
(4,267 Views)

Are you sure that's really how the string comes out?  I suspect you're looking for literal strings of \s when you should be looking for a space.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 15
(4,226 Views)

If instead of counting between the commas I turn into an array and perform the count?

 

image.png

0 Kudos
Message 4 of 15
(4,196 Views)

I still am doubtful that those \s are literally what you are looking for.  Or is that string indicator in backslash display mode?  If it is, this is a great time to learn that if you have controls, indicators, and/or constants that aren't displaying in their default fashion, it's pretty mandatory that you show this on your object by showing the radix on a numeric or the display mode on a string to avoid this kind of confusion.

 

Edit: I am leaving this post up even after figuring out what display mode the control is in so you can learn a bit about coding for other devs.  (Just beause you know what display mode the control is in doesn't mean anyone else does.)

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 15
(4,181 Views)

What I need is to count the number of characters, and I also need to know what character is and what is space (\s). I can get the string convert to array and do these counts in the array, no problem.

0 Kudos
Message 6 of 15
(4,173 Views)

Oh well, now I that I've decoded the picture  - I'm much better at decoding actual code - I see that the string control is actually in backslash mode, given the search string.  So Raven has beaten me by a day.  😉

 

But I'm wondering why you have to do this.  What is it going to help you to do?  Maybe there's a better way to do whatever it is you're trying to accomplish?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 15
(4,171 Views)

BTW - Search and Replace with "all" returns the number of replacements made, so you can use that in a loop and just add up all the results.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 15
(4,158 Views)

Count between commas.png

 

Pretty flexible solution, if you know reg.ex.'s.

 

, must match exact character (comma)

([^,]*) Matches 0-n characters that are not a comma, and return in first capturing group

, must match exact character (comma)

0 Kudos
Message 9 of 15
(4,138 Views)
Below is what I did. I changed the spaces by * and then converted to array. How could I now, from this array, count the characters of each value?

 

image.png

0 Kudos
Message 10 of 15
(4,125 Views)