How do I reverse a string

I have a string called “009512-nhoJ KraM.” I would like to reverse the word after the hyphen and place the reversed word in front, so it becomes:

Mark John-009512

Hi @The_Automation_king,
you can use this formula:

New String(yourstring.split("-“c)(1).Reverse().ToArray()) + “-” + yourstring.split(”-"c)(0)

1 Like

Hello,

This can be easily done using linq method “Reverse” returning an Enumerable of characters.

exemple:

Assign activity
res = yourString.Reverse().ToArray()

You have specific requirement with the hyphen so should probably be:

string.Concat(yourString.Split("-")(1).Reverse().ToArray(),
"-",
yourString.Split("-")(0)
)
1 Like

Hello @The_Automation_king

This would help. in assign activity, assign your string to : String.Join(String.Empty,yourString.Split("-"c)(1).Reverse())+"-"+yourString.Split("-"c)(0)

The results are shown below:

Thank you

Cheers

1 Like

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