Solved

Regex Question

Posted on 2004-04-21
1
206 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
ID: 10881624
$line='1,2,5-7,9-12,15,18,20-22';

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

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Extract multiple value with delimiters from a string 4 170
perl script help 12 104
combine multiple lines 2 60
Perl Untar File 1 42
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 …
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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 shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

776 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