How to change all but one instance of a char

in my incoming data i get two variables
[name middle middle middle] and [last name]
i have to change it into two names as ["first name "][“middle_middle_lastname”]
how do i replace all space except for the first space?
it can vary how many middlenames there are in the data i get in.

I think the logic will be that when you get the variables:

  1. you can substring the 1st variable on the basis of ’ '[space] so you get firstname.
  2. assign that to your your first output variable = str.Substring(0, str.IndexOf(" "))
  3. then you can you a assign second output variable = (concat str.Substring(str.IndexOf(" ")+1)+"_"+var2).Replace(" ","_") in a single expression.

Thanks i’ll try that once i get back to the desk

1 Like