Remove multiple blanks from a string

good morning, I would like to remove multiple blanks from a string, currently I use assign srtPDF.Replace (" ", “”)

I want to leave the whole string with a single white space separations, since in the string there are up to 3 white spaces and sometimes 2, this that I put, sometimes works for me … some alternative


Use this regex pattern in matches activity



I can’t understand your solution, if I have a string with 2 spaces, how do I leave it in a single space?


You can just add one more extra space in the replace

varStr.Replace("  ","").ToString
1 Like

After macthes in assign write this syntax

strText - string, mtchColl - Matches output variable

strText = string.join(" ",mtchColl.Cast(of match).Select(function(d) d.ToString).toarray)


matches Input String


Output String in message box


Please mark it as solution if it hepls. Thanks

Replacing 2 or more whitespace:

output = System.Text.RegularExpressions.Regex.Replace(your_String, "\s{2,}" , " ")

output = String
your_String= String

Preview link: regex101: build, test, and debug regex

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.