From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

string ranges

Solved!
Go to solution

How can I split a string range into a list or an array

say

1002..1004,1009,1100..1102

to a list like

1002, 1003, 1004, 1009, 1100, 1101 ,1102

or an array

 

0 Kudos
Message 1 of 6
(2,283 Views)

Can you guarantee that the input is well formed (all integers, comma delimited singles, ".." delimited ranges (not "." or "..."), no weird other characters, all one single line, all ranges going from smaller to bigger, etc.

 

In that case, seems easy. What have you tried so far?

0 Kudos
Message 2 of 6
(2,272 Views)
Solution
Accepted by topic author DanlB

Here's one simple possibility (LV2015):

 

expandRanges.png

Message 3 of 6
(2,249 Views)

And to allow ranges in both directions, here's how you would modify the default case.

 

expandRangesupdown.png

Message 4 of 6
(2,240 Views)

I was hoping for a nice clean function.

I made a parser that works but it is definitely not clean

a couple of your parsing ideas simplified my version

thanks

0 Kudos
Message 5 of 6
(2,219 Views)

@DanlB wrote:

I was hoping for a nice clean function.

I made a parser that works but it is definitely not clean

a couple of your parsing ideas simplified my version

thanks


Make it into a subVI.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 6 of 6
(2,128 Views)