I am coding in Fortran 95.
I must extract the two floating values from this line in an ascii file:
circle(4097.0438,4111.337)
Of course the READ statement is
read(unit=11, fmt="(tr7,f9.4,tr1,f8.3)") x, y
The problem is that I must do that for hundreds of ascii files, but there are variations in the number of digits. For instance:
circle(201.043,7250.1234) # which would require fmt="(tr7,f7.3,tr1,f9.4)"
circle(0.004038,9999.12) # which would require fmt="(tr7,f8.6,tr1,f7.2)"
circle(0.004038,22.1234) # etc
Therefore I cannot use a single format. I don't know how to read those x, y coordinates using free format because I must skip the first 7 spaces anyway.
Reading in the data into a string buffer and removing unnecessary parts probably work.
Another way is to use index() to find "(" and ") [please see ref also]. In this case the data may contain any string before "(" or after ")". Similar methods can be used to extract necessary parts in more complicated cases.