Regex Question

I have a string in the following form:

1,2,5-7,9-12,15,18,20-22

What regex can I use to split this string so that I have an array containing the following elements:

5-7
9-12
20-22

Thanks.
pcarrollnfAsked:
Who is Participating?
 
fim32Connect With a Mentor Commented:
$line='1,2,5-7,9-12,15,18,20-22';

@blah = $line =~ /(\d+-\d+)/g;
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.