CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
regular expression

 



shinyhui
New User

Dec 5, 2012, 7:15 PM

Post #1 of 3 (958 views)
regular expression Can't Post

i've a list of files

Quote
ABC1.txt
ABC1a_1.txt
ABC1a_1_1.txt
ABC1b.txt
ABC1b_1.txt
ABC11.txt
ABC1.png


what the regex i should use where only these 4 files is list


Quote
ABC1.txt
ABC1a_1.txt
ABC1a_1_1.txt
ABC1b.txt
ABC1b_1.txt



BillKSmith
Veteran

Dec 5, 2012, 7:54 PM

Post #2 of 3 (956 views)
Re: [shinyhui] regular expression [In reply to] Can't Post


Code
use strict; 
use warnings;
my @files = (
'ABC1.txt',
'ABC1a_1.txt',
'ABC1a_1_1.txt',
'ABC1b.txt',
'ABC1b_1.txt',
'ABC11.txt',
'ABC1.png',
);

my @special_files = grep {/ABC1(:?a_1|a_1_1|b|b_1)?\.txt/} @files;
print "@special_files\n";

Good Luck,
Bill


shinyhui
New User

Dec 5, 2012, 9:47 PM

Post #3 of 3 (954 views)
Re: [BillKSmith] regular expression [In reply to] Can't Post

what about do not accept pattern [0-9]?

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives