Solved

perl, how to extract pattern into an array

Posted on 2011-03-23
2
478 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
Comment Utility
my @arr = $string =~ m{(YEAR_\d\d)}g;
0
 

Author Closing Comment

by:rgbcof
Comment Utility
That works great.  Thanks.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

763 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

8 Experts available now in Live!

Get 1:1 Help Now