# Need help with string variable formatting

**URL:** <https://forums.unrealengine.com/t/need-help-with-string-variable-formatting/474102>\
**Category:** Editor Scripting\
**Tags:** arrays, string, foreachloop, unreal-engine, question\
**Created:** [November 6, 2020, 5:42pm UTC](https://forums.unrealengine.com/t/need-help-with-string-variable-formatting/474102 "2020-11-06T17:42:02Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shedels](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shedels/32/1121823_2.png) [@Shedels](https://forums.unrealengine.com/u/Shedels)\
**Post date:** [November 6, 2020, 5:42pm UTC](https://forums.unrealengine.com/t/need-help-with-string-variable-formatting/474102/1 "2020-11-06T17:42:02Z")

</div>

I have string: 1234567890

How can i make it look like: 12 34 56 78 90?

---

<div class="post-metadata">

**Author:** ![Detach789](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Detach789](https://forums.unrealengine.com/u/Detach789)\
**Post date:** [November 6, 2020, 6:02pm UTC](https://forums.unrealengine.com/t/need-help-with-string-variable-formatting/474102/2 "2020-11-06T18:02:54Z")

</div>

Well, I’m assuming you are getting this string as a conversion from some other source that doesn’t allow spaces (otherwise, you could simply type “12 34 56 78 90” with the spaces in there yourself).

Would a format text node work for your uses? You could convert it from text back to string after you use it. [WTF Is? Text- Format Text in Unreal Engine 4 - YouTube](https://www.youtube.com/watch?v=TmJ3rSXacbE)

---

<div class="post-metadata">

**Author:** ![Shedels](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shedels/32/1121823_2.png) [@Shedels](https://forums.unrealengine.com/u/Shedels)\
**Post date:** [November 6, 2020, 6:55pm UTC](https://forums.unrealengine.com/t/need-help-with-string-variable-formatting/474102/3 "2020-11-06T18:55:17Z")

</div>

No i think it’s not right idea.  
Maybe algorithm with loop will be much better for this work.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [November 6, 2020, 11:11pm UTC](https://forums.unrealengine.com/t/need-help-with-string-variable-formatting/474102/4 "2020-11-06T23:11:50Z")

</div>

9/10 there is a need to divide something into pieces, you’d use modulo:

 ![321332-screenshot-2020-11-06-231033.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/8/a/38a4e5be90f0625ceea54a4b11881aa882f7d11c.jpeg)

There might exist a more elegant way but it’s late here… 😑

---

<div class="post-metadata">

**Author:** ![EvilCleric](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@EvilCleric](https://forums.unrealengine.com/u/EvilCleric)\
**Post date:** [November 7, 2020, 7:14am UTC](https://forums.unrealengine.com/t/need-help-with-string-variable-formatting/474102/5 "2020-11-07T07:14:01Z")

</div>

Following Everynone tip on the module:

(I used | instead of space, just for clarity)

 ![321343-1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/4/e/24eb94587e654d71bece56c7e90d7ab40a6cc06d.jpeg)

Result:

12|34|56|78|90

---

<div class="post-metadata">

**Author:** ![Shedels](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shedels/32/1121823_2.png) [@Shedels](https://forums.unrealengine.com/u/Shedels)\
**Post date:** [November 7, 2020, 8:06am UTC](https://forums.unrealengine.com/t/need-help-with-string-variable-formatting/474102/6 "2020-11-07T08:06:16Z")

</div>

![321352-123323.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/e/d/fed96fd425012c0c8d21af454e79733d6ac1dfee.png)

But how?  
I can’t figure out where the error is. INSERT seems to give +1 to the array and give an error.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [November 7, 2020, 8:15am UTC](https://forums.unrealengine.com/t/need-help-with-string-variable-formatting/474102/7 "2020-11-07T08:15:06Z")

</div>

Ah, I see, inserting is more logical here. That looks cleaner and neater!

---

<div class="post-metadata">

**Author:** ![EvilCleric](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@EvilCleric](https://forums.unrealengine.com/u/EvilCleric)\
**Post date:** [November 7, 2020, 8:26am UTC](https://forums.unrealengine.com/t/need-help-with-string-variable-formatting/474102/8 "2020-11-07T08:26:21Z")

</div>

Reverse loop.

---

<div class="post-metadata">

**Author:** ![Shedels](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shedels/32/1121823_2.png) [@Shedels](https://forums.unrealengine.com/u/Shedels)\
**Post date:** [November 7, 2020, 8:27am UTC](https://forums.unrealengine.com/t/need-help-with-string-variable-formatting/474102/9 "2020-11-07T08:27:16Z")

</div>

What’s the different?Just to understand.

---

<div class="post-metadata">

**Author:** ![EvilCleric](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@EvilCleric](https://forums.unrealengine.com/u/EvilCleric)\
**Post date:** [November 7, 2020, 8:38am UTC](https://forums.unrealengine.com/t/need-help-with-string-variable-formatting/474102/10 "2020-11-07T08:38:37Z")

</div>

Reverse loop: last to first

Normal loop: first to last.
