Word swap in uipath

Hi All,

If possible, Pls give solution below mentioned format

Input string : Dhoni MS.

I expected Output : MS Dhoni

@AJITH_SK,

Follow these steps:

  1. Assign: inputString = “Dhoni MS.”

  2. Assign: firstName = inputString.Split(" "c)(1)

  3. Assign: lastName = inputString.Split(" "c)(0)

  4. Assign: outputString = firstName.Trim() + " " + lastName.Trim()

  5. Write Line: outputString

Thanks,
Ashok :slight_smile:

grafik

But we guess that more variations on the input should be analyzed in advance

1 Like

That’s a lot of extra work for no reason.

Just do…

inputString = inputString.Split(" "c)(1) + " " + inputString.Split(" "c)(0)

Creating all those extra variables is unnecessary.

Hi @AJITH_SK

Use below syntax in Assign activities:

inputString = "Dhoni MS."

outputString = String.Join(" ", inputString.Split(" "c).Reverse())

Regards

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.