Consider the following list:
filenamesSensitivity = {"Sensitivity_MCP_at_LAr-SHiP-ECN3_target_Electrons_Npot=6.e20_Nbg=1._nhits=1._Eemin=0.03.dat", "Sensitivity_MCP_at_SND-SHiP-ECN3_target_Electrons_Npot=6.e20_Nbg=1.dat"};
I want to extract the parameters from these filenames. They have different number of parameters (the first string has two extra parameters in the end), so two different commands are needed:
ParametersSensitivityTemp[i_] :=
StringCases[filenamesSensitivity[[i]],
"Sensitivity_MCP_at_" ~~ experiment__ ~~ "_target_" ~~ target__ ~~
"_Npot=" ~~ Npot__ ~~ "_Nbg=" ~~ Nbg__ ~~ ".dat" :> {experiment,
target, Npot, Nbg}][[1]]
ParametersSensitivityLArTemp[i_] :=
StringCases[filenamesSensitivity[[i]],
"Sensitivity_MCP_at_" ~~ experiment__ ~~ "_target_" ~~ target__ ~~
"_Npot=" ~~ Npot__ ~~ "_Nbg=" ~~ Nbg__ ~~ "_nhits=" ~~ nhits__ ~~
"_Eemin=" ~~ Eemin__ ~~ ".dat" :> {experiment, target, Npot,
Nbg, nhits, Eemin}][[1]]
The first command is expected to extract the parameters from the second string, while the second - from the first string. In the end, I get this:
list1 = Table[
ParametersSensitivityTemp[i], {i, 1,
Length[filenamesSensitivity]}] // TableForm
list2 = Table[
ParametersSensitivityLArTemp[i], {i, 1,
Length[filenamesSensitivity]}] // TableForm
The desired output looks like the two rows - the second row in the first table and the first row in the second table.
So ParametersSensitivityTemp
treats 1._nhits=1._Eemin=0.03
from the first string as a single parameter, while ParametersSensitivityLArTemp
obviously fails to extract the parameters from the second string.
Could you please tell me how to fix these commands such that each of them would work only with the appropriate strings?
StringSplit[filenamesSensitivity, {"-" | "_"}]
$\endgroup$ParametersSensitivityTemp
). $\endgroup$StringSplit[filenamesSensitivity, {"_"}]
$\endgroup$