Solved

Regex Question

Posted on 2004-04-21
1
205 Views
Last Modified: 2010-03-04
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
Comment
Question by:pcarrollnf
1 Comment
 
LVL 7

Accepted Solution

by:
fim32 earned 50 total points
Comment Utility
$line='1,2,5-7,9-12,15,18,20-22';

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

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now