The string below contains two "?" what calculated column formula should I use to replace the second "?" with "&" but not remove the "?" from other strings that have only one "?"

Could anyone please provide the appropriate code to replace the second instance only of "?" in a string with a "&" ?


Use the following:

var index = input.IndexOf('?', input.IndexOf('?') + 1);
var ouput = string.Concat(input.Substring(0,index), "&", input.Substring(index + 1));


var output = new string(input.Select((c, i) => i == index ? '&' : c).ToArray());

Credit goes to: https://stackoverflow.com/questions/23547100/replace-second-occurence-of-with-an

  • I'm looking to use a calculated formula. Can this work has a calculated formula? Thank you
    – user61554
    Nov 4 '16 at 11:27
  • Can you help with providing the appropriate code to replace the second instance only of "?" in a string with a "&" ?
    – user61554
    Nov 4 '16 at 11:55

Get it working Excel first, saves you SP headaches
You only need the basic functions, and the syntax in SharePoint Formulas is the same

Here is a list of functions that work in SharePoint Formulas: http://www.viewmaster365.com/365coach/#/Calculated_Column_Functions_List

Pseudo code:

  • Get the string after the first ?
  • In that string replace the ?

Note: SharePoint has no SUBSTITUTE function to replace all characters,
you can do it with nested functions:

StackOverflow: Calculated Column Formula how to replace Substitute

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.