To replace multiple words from an input string, there's no easy way to carry out this task except to nest multiple calls to Substitute function like so:
Set(varInputString, "Mon 1st March 2022")
Substitute(
Substitute(
Substitute(
Substitute(
Substitute(
Substitute(
Substitute(
varInputString,
"Mon",
"Monday"
),
"Tue",
"Tuesday"
),
"Wed",
"Wednesday"
),
"Thu",
"Thursday"
),
"Fri",
"Friday"
),
"Sat",
"Saturday"
),
"Sun",
"Sunday"
)
This type of structure is difficult to write and maintain. Therefore, I suggest that it would be helpful if the Substitute function could be enhanced to support multiple replacements. The enhanced usage would look like this:
Substitute(varInputString,
"Mon","Monday",
"Tue","Tuesday",
"Wed","Wednesday",
"Thu","Thursday",
"Fri","Friday",
"Sat","Saturday",
"Sun","Sunday"
)
If it's difficult to extend the Substitute function due to the use that includes the optional 'InstanceNumber' argument, I would propose a new function called SubstituteMultiple to carry out this task.
Many thanks for your consideration.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.