Solved

perl, how to extract pattern into an array

Posted on 2011-03-23
2
498 Views
Last Modified: 2012-06-27
$string = "First YEAR_95, then YEAR_97,  then YEAR_99";
How to extract pattern YEAR_nn in to an array so $ary[0] = 'YEAR_95', $ary[1] = 'YEAR_97', and so on.
0
Comment
Question by:rgbcof
2 Comments
 
LVL 26

Accepted Solution

by:
wilcoxon earned 250 total points
ID: 35202544
my @arr = $string =~ m{(YEAR_\d\d)}g;
0
 

Author Closing Comment

by:rgbcof
ID: 35202585
That works great.  Thanks.
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

In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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 Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

813 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

14 Experts available now in Live!

Get 1:1 Help Now