I have a long string (FileName) from which I would like to extract some variables describing the X values. The string contins this format:
"... X 1.5-2.8 mm ... "
from which I successfuly can extract the range (from 1.5 to 2.8) with:
[v,vv]=regexp(FileName,[' X ([\d\.]){1,10}-([\d\.]){1,10} mm'],'tokens','match');
However, when the range includes a minus sign this does not work very well...
I've tried including the minus sign like this:
[v,vv]=regexp(FileName,[' X ([-\d\.]){1,10}-([-\d\.]){1,10} mm'],'tokens','match');
But that will for example give me (if FileName contains "-1.5-2.8") a range of from "-1.5-" to "2.8".
How can I get this line of code to work with these formats:
X 4--8 mm (where the range is from 4 to -8 mm)
X -4-8 mm
X -4--8 mm
or do I need to make a regexp for each of these cases separately?