Oct 30, 2002 #1 jmdc MIS Joined Feb 2, 2001 Messages 19 Location US $line = aaa_A43.bbb11_07172002_00.ab.err @line = split(/[a-zA-Z_.]+/, $line); This is what I get - 43 11 07172002 00 How can I make @line = "07172002" Please Help.
$line = aaa_A43.bbb11_07172002_00.ab.err @line = split(/[a-zA-Z_.]+/, $line); This is what I get - 43 11 07172002 00 How can I make @line = "07172002" Please Help.
Oct 30, 2002 #2 goBoating Programmer Joined Feb 8, 2000 Messages 1,606 Location US Here is a rough stab at it. Code: #!perl $line = 'aaa_A43.bbb11_07172002_00.ab.err'; if ($line =~ /\w+_\w+\.\w+_(\d+)_\d+\.\w+\.\w+/) { print "chunk: $1\n"; } You will likely need to adjust the regex to better suit your case. 'hope this helps If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo. Upvote 0 Downvote
Here is a rough stab at it. Code: #!perl $line = 'aaa_A43.bbb11_07172002_00.ab.err'; if ($line =~ /\w+_\w+\.\w+_(\d+)_\d+\.\w+\.\w+/) { print "chunk: $1\n"; } You will likely need to adjust the regex to better suit your case. 'hope this helps If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
Oct 30, 2002 Thread starter #3 jmdc MIS Joined Feb 2, 2001 Messages 19 Location US This worked thanks, Now for the next problem I put this into an array like I did above. How do I get rid of the space before the numbers? -Justin Upvote 0 Downvote
This worked thanks, Now for the next problem I put this into an array like I did above. How do I get rid of the space before the numbers? -Justin
Oct 31, 2002 1 #4 Parke Programmer Joined Jan 10, 2001 Messages 51 Location US If the format of the string is always the same, try #!/c:/perl/bin/perl.exe # splitting a string on _ use diagnostics; $line = 'aaa_A43.bbb11_07172002_00.ab.err'; (undef,undef,$wanted,undef) = split('_',$line); print "$wanted\n"; Upvote 0 Downvote
If the format of the string is always the same, try #!/c:/perl/bin/perl.exe # splitting a string on _ use diagnostics; $line = 'aaa_A43.bbb11_07172002_00.ab.err'; (undef,undef,$wanted,undef) = split('_',$line); print "$wanted\n";