Hi all,

I need to remove more than a white space from a string in an expression. The problem is that i don't know how many spaces it could be. Example:

"Have a         good day" - to:

"Have a good day"


Hugo Castro
Replace (built-in action) double espaces ("  ") for an empty string.
Paulo Ramos wrote:
Replace (built-in action) double espaces ("  ") for an empty string.
 Hi Paulo,

You gave me an example to double spaces and if there is more than 2 spaces.
Has i said i down't know how many white spaces could be...
flashed wrote:
 Hi Paulo,

You gave me an example to double spaces and if there is more than 2 spaces.
Has i said i down't know how many white spaces could be...
As I remember, the OS built-in Replace action replaces all occurrences in the string (in just one shot).
But if that's not the case, simply keep replacing double spaces in a loop, until the input string is equal to the output string (meaning there are no more spaces to remove).
I believe there is a more generic option. You can use a regular expressions to replace all spaces for a single space:
  1. Go to the Add/Remove references window
  2. Go to the "Text" extension and reference the "Regex_Replace" action
On your logic use this action to replace multiple spaces:
  • Text: use the variable holding the text you want to clean up
  • Pattern: "\s+"  (one or more spaces)
  • Replace: " " (a single space) 
As an example:
nvm, too late :) see Joao's suggestion
Thanks a lot to all. João Ferrnandes  it works, thanks.
I didn't kown this extension. Next time i will look to all extensions before i post any doubt here.

Best regards!

Hugo Castro
There is no problem in asking.
In fact, while answering your question I also learned something new, so it was a win-win situation for me.

As Tiago Simoes told in his Next Step session, if you share (both your knowledge and doubts), your experience will increase and others will help you later.

Not only that, because of your "asking" you allowed a lot of people to learn a great fix without going through all the trouble you went through.

So, thank you and keep those questions coming!   ;o)

Great job , good learning...! 

Hugo, because of every initiator other people learn something. Every doubt is doubt, it's not small one or big one. If we don't know something, it means that we never touched that part. There's no hesitation in asking. After spending 2.5 years with OutSystems, I still keep asking silly questions for which people scold me a lot but at the end intention is to learn.

Thanks and Regards,

Suraj Borade

Thanks for sharing!

People, you're necroing a 4+ yo thread. Please check the post date when replying!

Sorry sir,

I just checked last person's reply.

Great solution!

Thanks to Hugo Castro for raising their doubts, was also mine.

João Fernandes thanks to the spectacular solution and the way introduced.

Macro101 for the comment, because it put the solution in front of my eyes!

Good example of the community working!

That is the point Kilian, a 4-year old post still important today. I (and apparently, at least one other) had no idea how to "easily" remove spaces from a text column. This was very important to me. Thanks to Google, it presented a 4-year old post with the perfect solution. 

Not to mention the fact it exposed a very interesting unknown section of "text actions" (to me).

By just the act of saying "thanks", it brings the post back to the front again and, hopefully, helps others to know there are many wonderful ways of doing stuff in outsystems using general extensions.


You might want to add another validation on the assign after the Regex_Replace, like this:

That way you will remove any leading and trailing white spaces that may be left by the Regex_Replace.

Macro01, posts go pretty quickly here, and after a few days or so aren't visible on the front page, so your point is moot. Also, necroing threads is just not done.

@Tiago: I forgot in my previous post, but with the right regular expression, you can also remove the trailing spaces in one go.