TRIM Spaces from Text as a Command or Express...

Colin1
New Member

TRIM Spaces from Text as a Command or Expression?

Is there some sort of command or expression that can trim text from either end of a text string, please?

I assumed there was one, but upon searching, oddly I cannot find one or it does not exist.

OPAT

0 11 1,139
11 REPLIES 11

Would you please give us a sample what you are looking for, thanks.

Colin1
New Member

@Aleksi_Alkio For example:

"

The quick brown fox jumps over the lazy dog.

"

becomes

โ€œThe quick brown fox jumps over the lazy dog.โ€

Is the start and end โ€œstringโ€ always the same like four spaces?

Colin1
New Member

@Aleksi_Alkio No, it could be many or a few.

Are these values coming from a different service?

Colin1
New Member

I am something that behaves like these functions ideally:

docs.microsoft.com - LTrim, RTrim, and Trim functions | Microsoft Docs

and this:

https://www.tutorialspoint.com/java/java_string_trim.htm LTrim, RTrim, and Trim functions | Microsoft Docs docs.microsoft.com

We should have a Trim function! Will get it in next week.

Actually, it will be on Monday! :]

Colin1
New Member

@praveen Wow! A new Function in just 7 minutes! It must be an Appsheet record! Thanks!

Hopefully, it might address a minor cosmetic anomaly I encountered yesterday.

Okayโ€ฆ I gave up. You can of course create that filter with existing expressions, but it would be quite complex. Praveenโ€™s solution is much quicker

You can trim spaces from a text using trim() method of String class.

public class StringTrimJava
{
   public static void main(String[] args)
   {
      String str = "     welcome to helloworld java!        ";
      System.out.println(str);
      System.out.println(str.trim());
   }
}

Output:
welcome to helloworld java!

Top Labels in this Space