Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted

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

Jump to solution

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?

0 Kudos
1 Solution

Accepted Solutions
Highlighted

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

Jump to solution

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)

View solution in original post

0 Kudos
1 Reply
Highlighted

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

Jump to solution

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)

View solution in original post

0 Kudos