Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
chaklasiyanikun
Roku Guru

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
chaklasiyanikun
Roku Guru

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 1
chaklasiyanikun
Roku Guru

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)
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.