Wednesday, October 31, 2018

Using TRIM, LTRIM, and RTRIM for Formula functions

This article gives examples on using some common string functions that can be used for NetSuite search formulas via user interface or script, and on custom formula fields.
 

TRIM: Removes leading or trailing characters (or both) from a character string

  • Syntax: TRIM([ { { LEADING | TRAILING | BOTH } [ trim_character ]| trim_character}FROM ]trim_source)
  • Examples:
     TRIM('   test   '); //returns 'test'
     TRIM(' '  FROM  '   test   '); //returns 'test'
     TRIM(LEADING '0' FROM '000123');  //returns '123'
     TRIM(TRAILING '1' FROM 'Test1');  //returns 'Test'
     TRIM(BOTH '1' FROM '123Tech111');  //returns '23Test'
 

LTRIM : Removes all specified characters (on 'set' parameter) from the left side of a string.
If 'set' parameter is omitted, the LTRIM function will remove all trailing spaces on the left from 'char'.

  • Syntax: LTRIM(char [, set ])
  • Examples:
     LTRIM('   test');  //returns 'test'
     LTRIM('000123', '0'); //returns '123'
     LTRIM('123123Test123', '123'); //returns 'Test123'
     LTRIM('abcacccTest', 'abc'); //returns 'Test'
 

RTRIM: Removes all specified characters from the right side of a string
If 'set' parameter is omitted, the RTRIM function will remove all trailing spaces on the right from 'char'.

  • Syntax:  RTRIM(char [, set ])
  • Examples:
     RTRIM('test   '); //returns 'test'
     RTRIM('test   ', ' '); //returns 'test'
     RTRIM('123000', '0'); //returns '123'
     RTRIM('Test0387', '0123456789');  //returns 'Test'


No comments:

Post a Comment