J
j2ee
I have a file which has these 3 columns (for example)
Name Size1 Size2
+ abc_p.h 12345 432
*unknown
+ dfe_e_io.h 210989 123
+ dfx_e_io.c 210912 1290 and so on upto 500 entries.
I have to retreive Name(file names) and size1 and store it in an array
Then I have to retrieve name and size2 and store it in another array
My solution:
I checked if the each line in the file matched the file name using regular
expression. If there is match then store those filenames and size1 in array1
using substr operation.
But the problem is I hardcoded the values of starting position and
length of the string in the substr operation. So my code will work only for a
given length of string. for eg. say 20. If a name is of lenght> 20, my code
won't work.
Can you tell if there is a generic way of writing regular expression that
matches the name in my file , and then size1 and stores them in a array? Special
cases: IN the name column you may have some unwanted string like *unknown which
should be ignored.
Let me know if you need clarifications. Thanks..
Name Size1 Size2
+ abc_p.h 12345 432
*unknown
+ dfe_e_io.h 210989 123
+ dfx_e_io.c 210912 1290 and so on upto 500 entries.
I have to retreive Name(file names) and size1 and store it in an array
Then I have to retrieve name and size2 and store it in another array
My solution:
I checked if the each line in the file matched the file name using regular
expression. If there is match then store those filenames and size1 in array1
using substr operation.
But the problem is I hardcoded the values of starting position and
length of the string in the substr operation. So my code will work only for a
given length of string. for eg. say 20. If a name is of lenght> 20, my code
won't work.
Can you tell if there is a generic way of writing regular expression that
matches the name in my file , and then size1 and stores them in a array? Special
cases: IN the name column you may have some unwanted string like *unknown which
should be ignored.
Let me know if you need clarifications. Thanks..