ee.String.trim

Returns a string whose value is the original string, with any leading and trailing whitespace removed.
Usage Returns
String. trim () String
Argument Type Details
this: string
String The string to trim.

Examples

Code Editor (JavaScript)

 var 
  
 s 
  
 = 
  
 ee 
 . 
 String 
 ( 
 '\t\n\r abc\t\n\r ' 
 ); 
 print 
 ( 
 s 
 . 
 trim 
 ()); 
  
 // "abc" 
 var 
  
 s 
  
 = 
  
 ee 
 . 
 String 
 ( 
 ' a\t\n\r b ' 
 ); 
 print 
 ( 
 s 
 . 
 trim 
 ()); 
  
 // "a\t\n\r b" 

Python setup

See the Python Environment page for information on the Python API and using geemap for interactive development.

 import 
  
 ee 
 import 
  
 geemap.core 
  
 as 
  
 geemap 

Colab (Python)

 s 
 = 
 ee 
 . 
 String 
 ( 
 ' 
 \t\n\r 
 abc 
 \t\n\r 
 ' 
 ) 
 print 
 ( 
 s 
 . 
 trim 
 () 
 . 
 getInfo 
 ()) 
 # "abc" 
 s 
 = 
 ee 
 . 
 String 
 ( 
 ' a 
 \t\n\r 
 b ' 
 ) 
 print 
 ( 
 s 
 . 
 trim 
 () 
 . 
 getInfo 
 ()) 
 # "a\t\n\r b" 
Create a Mobile Website
View Site in Mobile | Classic
Share by: