# What's the best way to remove letters and special characters from a string?

**URL:** <https://forums.unrealengine.com/t/whats-the-best-way-to-remove-letters-and-special-characters-from-a-string/765060>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, Blueprint, question\
**Created:** [February 6, 2023, 7:37pm UTC](https://forums.unrealengine.com/t/whats-the-best-way-to-remove-letters-and-special-characters-from-a-string/765060 "2023-02-06T19:37:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![andbc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@andbc](https://forums.unrealengine.com/u/andbc)\
**Post date:** [February 6, 2023, 7:37pm UTC](https://forums.unrealengine.com/t/whats-the-best-way-to-remove-letters-and-special-characters-from-a-string/765060/1 "2023-02-06T19:37:05Z")

</div>

Hi,

I’m trying to remove letters and other special characters from a string but I’m not finding the best way to do it. I’ve tried the Replace function but it only works with a single character at a time or a complete string.

What I’m trying to accomplish is to only keep the digits on the string, for example, If the user writes ‘123M€’, I want to get the ‘123’, so I can make some math with it later.

Thank you!

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [February 6, 2023, 8:36pm UTC](https://forums.unrealengine.com/t/whats-the-best-way-to-remove-letters-and-special-characters-from-a-string/765060/2 "2023-02-06T20:36:20Z")

</div>

I don’t think there’s a fancy filter. You could break it into an array, and remove the bad ones as you append it back into a string

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/a/6/ca61556eba260b71f9a4a34bd2d17b395aa19a0b.png)

---

<div class="post-metadata">

**Author:** ![andbc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@andbc](https://forums.unrealengine.com/u/andbc)\
**Post date:** [February 7, 2023, 11:42am UTC](https://forums.unrealengine.com/t/whats-the-best-way-to-remove-letters-and-special-characters-from-a-string/765060/3 "2023-02-07T11:42:30Z")

</div>

Thank you for your response! 🙂

I’m not sure I understand you right, this is what I tried to do:

 ![print](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/7/c/b7cc68dc774f54f7f493508b63e7b14c3ce503f2.png)

On my ‘Value 1’ I have the string ‘123M€’  
On my ‘Characters to remove’ I have the string ‘abcdefghijklmnopqrstuvwxyz€$%’

I’m sure I’m doing it wrong cause it’s not working…

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [February 7, 2023, 11:51am UTC](https://forums.unrealengine.com/t/whats-the-best-way-to-remove-letters-and-special-characters-from-a-string/765060/5 "2023-02-07T11:51:33Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/2/9/b29fdb72549d75950f2e7d544b221060265e229f.png)

---

<div class="post-metadata">

**Author:** ![andbc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@andbc](https://forums.unrealengine.com/u/andbc)\
**Post date:** [February 9, 2023, 9:04pm UTC](https://forums.unrealengine.com/t/whats-the-best-way-to-remove-letters-and-special-characters-from-a-string/765060/6 "2023-02-09T21:04:10Z")

</div>

Thank you, it worked perfectly!
