How to Remove more than one Extra Space between the two lines?

Do anyone know How to Remove more than one Extra Space between the two lines?

Here I tried two ways :

  1. trim() function But, It’s only Removed a Left and right side space.
  2. I apply to Replace(" ", “”) But, It only works with the Single Space.

And one Logic apply From C# like below. It’s Working :

'   Console.WriteLine("HEllo                                 World");
'   System.Text.RegularExpressions.RegexOptions options = System.Text.RegularExpressions.RegexOptions.None;
'   System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("[ ]{2,}", options);
'   string sentence = regex.Replace("HEllo                                 World", " ");
'   Console.WriteLine(sentence);

Same thing, I tried with Roku like below two ways:

    'First    
    ?"Hello                                    World"
    r = CreateObject("roRegex", "\s+", "")
    sentence = r.Replace("HEllo                                 World                          Google                     ", " ")
    print(sentence)

    'Second
    pattern = CreateObject("roRegex", "[ ]{2,}", "i")
    patternsentence =  pattern.Replace("HEllo                                 World                          Google                     ", " ")
    print(patternsentence)

But Here It’s Removing only First space in-between the two character like below :

HEllo World Google

Does anyone know How It’s possible?

I forgot to heard about ReplaceAll Function. Now, It’s working for me.

    pattern = CreateObject("roRegex", "[ ]{2,}", "i")
    patternsentence =  pattern.**ReplaceAll**("HEllo                                 World                          Google                     ", " ")
    print(patternsentence)