O
oldyork90
I have a string that contains numbers and ranges of numbers, like
'1 2 4-6 8 20 - 23' which translates as "include numbers 1, 2, 4, 5,
6, 8, 20, 21, 22, 23'
I can find the range "objects" with
while ($s =~ /(\d+ *- *\d+)/g) {
# work with $1
}
Is there a way to trim up this string during the loop so that when
it's done, the range "objects" are gone and I'm left with the discreet
list of digits. It would look like this when complete '1 2 8'
I can trim it up later with s/(\d+ *- *\d+)//g, but was wondering if
this could be a one step thing. Seems like it would be a common
operation... find it, cut it out, find the next. I don't want
anything complex... just wondering.
Thank you.
'1 2 4-6 8 20 - 23' which translates as "include numbers 1, 2, 4, 5,
6, 8, 20, 21, 22, 23'
I can find the range "objects" with
while ($s =~ /(\d+ *- *\d+)/g) {
# work with $1
}
Is there a way to trim up this string during the loop so that when
it's done, the range "objects" are gone and I'm left with the discreet
list of digits. It would look like this when complete '1 2 8'
I can trim it up later with s/(\d+ *- *\d+)//g, but was wondering if
this could be a one step thing. Seems like it would be a common
operation... find it, cut it out, find the next. I don't want
anything complex... just wondering.
Thank you.