diff --git a/Packages/MIES/MIES_WaveBuilder.ipf b/Packages/MIES/MIES_WaveBuilder.ipf index 5737633aba..8f8a50f8ce 100644 --- a/Packages/MIES/MIES_WaveBuilder.ipf +++ b/Packages/MIES/MIES_WaveBuilder.ipf @@ -2158,7 +2158,7 @@ End Function/S WB_FormulaSwitchToShorthand(variable channelType, string formula) variable numSets, i - string stimset, shorthand + string stimset, shorthand, regex if(isEmpty(formula)) return "" @@ -2171,7 +2171,8 @@ Function/S WB_FormulaSwitchToShorthand(variable channelType, string formula) shorthand = epochCombineList[i][%Shorthand] stimset = epochCombineList[i][%stimset] - formula = ReplaceString(stimset + "?", formula, shorthand) + regex = "(?i)\\b\\Q" + stimset + "\\E\\b\?" + formula = ReplaceRegexInString(regex, formula, shorthand) endfor return formula diff --git a/Packages/tests/Basic/UTF_WaveBuilder.ipf b/Packages/tests/Basic/UTF_WaveBuilder.ipf index c25691db12..ff43b24e3c 100644 --- a/Packages/tests/Basic/UTF_WaveBuilder.ipf +++ b/Packages/tests/Basic/UTF_WaveBuilder.ipf @@ -357,3 +357,23 @@ Function WB_StimsetWithNoEpochsAreNotSaved() CHECK_EQUAL_STR(ST_GetStimsetList(searchString = basename + "*"), "") End + +Function CombineStimsetSubStrings() + + string setNameA, setNameAA, setNameCombine + + setNameA = ST_CreateStimSet("setABC", CHANNEL_TYPE_DAC) + setNameAA = ST_CreateStimSet("newsetABC", CHANNEL_TYPE_DAC) + + setNameCombine = ST_CreateStimSet("setCombine", CHANNEL_TYPE_DAC) + + ST_SetStimsetParameter(setNameCombine, "Total number of epochs", var = 1) + ST_SetStimsetParameter(setNameCombine, "Type of Epoch 0", var = EPOCH_TYPE_COMBINE) + + ST_SetStimsetParameter(setNameCombine, "Combine epoch formula version", epochIndex = 0, str = WAVEBUILDER_COMBINE_FORMULA_VER) + ST_SetStimsetParameter(setNameCombine, "Combine epoch formula", epochIndex = 0, str = LowerStr(setNameA) + "?" + " + " + LowerStr(setNameAA) + "?") + + WAVE/Z wv = WB_CreateAndGetStimSet(setNameCombine) + CHECK_WAVE(wv, NUMERIC_WAVE) + CHECK_NO_RTE() +End