I would like regex(es) that can parse right-justified numeric values in a fixed length field with optional leading whitespace. (This is essentially FORTRAN output but there are many other tools that do this). I know the width of the field.
Assume the field is an integer of width 5 (I5). Then the following are all conformant numeric values:
" 123"
"12345"
"-1234"
" -1"
I can make no assumption about the previous and following fields. Thus the following is valid for I3,I5,I2:
"-121234512"
and yields the values -12, 12345 and 12.
There should be no additional code associated with the regex. I am using Java regex but I would like this to be fairly general (at least conformant with C#).
If this can be done for integers, I would also like the regex(es) for real numbers which include a decimal point, e.g. F10.3
" -12.123"