Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 216
  • Last Modified:

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.
0
pcarrollnf
Asked:
pcarrollnf
1 Solution
 
fim32Commented:
$line='1,2,5-7,9-12,15,18,20-22';

@blah = $line =~ /(\d+-\d+)/g;
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now