Consider the following string:
string = "Displacement_0.5_ToDecVol_38_FidLength_50";
I would like to extract the three numbers from it: {0.5,38,50}
. This is an attempt:
parameters =
StringCases[string,
"Displacement_" ~~ displacement : NumberString ~~ "_ToDecVol_" ~~
ToDecVol : NumberString ~~ "_FidLength_" ~~
FidLength : NumberString ~~ _ :> {displacement, ToDecVol,
FidLength}][[1]]//ToExpression
However, it returns only the first digit from the last number:
{0.5, 38, 5}
The same situation would happen if setting any other number, say 511, instead of 50: it drops the last digit. Could you please tell me how to fix the code?