Can anyone suggest a regular expression to extract the 8 digit numbers that can be submitted in a file that can have the following formats:
file format 1:
1,10000021
2,10000023
2,10000035
3,10000043
file format 2:
10000023
10000035
10000043
10000045
10000060
file format 3:
10000043,,zrous
10000045,,sjandw
10000060,,jnbro2
10000063,,eedwa
10000067,,empav
file format 4:
10000021/1
10000023/1
10000035/1
10000043/1
10000045/1
10000060/1
file format 5:
10000021/1,10000021
10000023/1,10000023
10000035/1,10000035
file format 6:
10000112,10002524,10000998,10000071,10000043,10000612,10000018,10000110,10000011,10000013
I'm currently using this code to iterate over each line in the file:
open(SDATA,">$file")||die "Could not open data file";
@filedata=<SDATA>;
close(SDATA);
foreach $line (@filedata){
chomp($line);
#@sid=split m!/\d{8}/!,$line;
#@sid=split m!,!,$line;
foreach $nline (@sid){
do something ....
}
}
TIA.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.