How do I perform this regex in order to extract the value of the variable
You can test everything out here:
I would like to extract the value of individual variables paying attention
to the different ways they have been defined. For example, for dtime we
want to extract 0.004. It also has to be able to interpret exponential
numbers, like for example for variable vis it should extract 10e-6.
The problem is that each variable has its own number of white spaces
between the variable name and the equal sign (i dont have control on how
they have been coded)
Text to test:
dtime = 0.004D0
case = 0
newrun = 1
periodic = 0
iscalar = 1
ieddy = 1
mg_level = 5
nstep = 20000
vis = 10e-6
ak = 10e-6
g = 9.81D0
To extract dtime's value this REGEX works:
(?<=dtime =\s)[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?
To extract dtime's value this REGEX works:
(?<=vis =\s)[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?
The problem is that I need to know the exact number of spaces between the
variable name and the equal sign. I tried using \s+ but it does not work,
why?
(?<=dtime\s+=\s)[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?
No comments:
Post a Comment