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!
B
5
S
3
Posts: 195
Reputation: 1,067

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
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

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!
B
5
S
3
Posts: 195
Reputation: 1,067

Post » Sat Oct 01, 2016 11:46 am

Image
Image

Code: Select all
RegexReplace(Text.Text,"\s\s+","g"," ")
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 33 guests

cron