# How do I reverse a string

**URL:** <https://forum.uipath.com/t/how-do-i-reverse-a-string/775458>\
**Category:** Studio\
**Tags:** studio, system, activities\
**Created:** [October 24, 2024, 11:18am UTC](https://forum.uipath.com/t/how-do-i-reverse-a-string/775458 "2024-10-24T11:18:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![The\_Automation\_king](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/the_automation_king/32/506902_2.png) [@The\_Automation\_king](https://forum.uipath.com/u/The_Automation_king)\
**Post date:** [October 24, 2024, 11:18am UTC](https://forum.uipath.com/t/how-do-i-reverse-a-string/775458/1 "2024-10-24T11:18:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![PeCour](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/pecour/32/176661_2.png) [@PeCour](https://forum.uipath.com/u/PeCour)\
**Post date:** [October 24, 2024, 11:23am UTC](https://forum.uipath.com/t/how-do-i-reverse-a-string/775458/2 "2024-10-24T11:23:50Z")

</div>

Hi @The_Automation_king,  
you can use this formula:

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

---

<div class="post-metadata">

**Author:** ![Matt67](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/matt67/32/462196_2.png) [@Matt67](https://forum.uipath.com/u/Matt67)\
**Post date:** [October 24, 2024, 11:27am UTC](https://forum.uipath.com/t/how-do-i-reverse-a-string/775458/3 "2024-10-24T11:27:36Z")

</div>

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:

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

```

```auto

```

---

<div class="post-metadata">

**Author:** ![MasterOfLogic](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/masteroflogic/32/515497_2.png) [@MasterOfLogic](https://forum.uipath.com/u/MasterOfLogic)\
**Post date:** [October 24, 2024, 11:32am UTC](https://forum.uipath.com/t/how-do-i-reverse-a-string/775458/4 "2024-10-24T11:32:04Z")

</div>

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:

 ![Before](https://global.discourse-cdn.com/uipath/original/4X/9/2/9/9297edfeb80559be32ea939bcde3a3e42d5c1919.png)

 ![After](https://global.discourse-cdn.com/uipath/original/4X/4/c/a/4caada388a817089869f7a19eb84cfe230150ffb.png)

Thank you

Cheers

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [October 27, 2024, 11:32am UTC](https://forum.uipath.com/t/how-do-i-reverse-a-string/775458/5 "2024-10-27T11:32:16Z")

</div>

Closed on October 27, 2024, 11:32am UTC

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