How do I replace multiple whitespaces with one?

Get help using Construct 2

Post » Wed Sep 28, 2016 9:17 pm

Hi,
I have some text where I removed many special characters with the replace expression in my program. Now I have too many whitespaces in between the words and I need to make sure that there only is one. How do I do that?
I already found something with the regexreplace expression, but I didn't really understand how it works. :/
Any help is appreciated! :)
Thanks!
Image
B
5
S
3
Posts: 193
Reputation: 1,063

Post » Wed Sep 28, 2016 9:47 pm

you can simply use replace(src," "," ") to turn double spaces into single spaces.

(The forum auto corrects the double spaces between the first set of quotations, so make sure you have two there, or however many you want.)
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Sat Oct 01, 2016 10:27 am

Thanks @oosyrag,
I was hoping to find a more dynamic solution, so that it can replace any number of whitespaces with one.
Your solution works though :)
Thanks again!
Image
B
5
S
3
Posts: 193
Reputation: 1,063

Post » Sat Oct 01, 2016 11:46 am

Image
Image

Code: Select all
RegexReplace(Text.Text,"\s\s+","g"," ")
Image
B
65
S
23
G
7
Posts: 1,505
Reputation: 10,896


Return to How do I....?

Who is online

Users browsing this forum: cb130felix, Kermad, Lancifer, Matei511, mongoose665, piddlyPoo, yiuyiu6666 and 3 guests