Skip to main content

$$trim

Removes whitespaces (or other selected characters) from sides of string

Usage

{ 
"$$trim": /* String to trim */,
"type": "BOTH" /* or START / END / INDENT / JAVA */,
"what": /* string */
}
"$$trim([type],[what]):{input}"
note

Concrete values in the usage example are default values.

Returns

string

Arguments

ArgumentTypeValuesRequired / Default ValueDescription
InputstringYesString to trim
typeenumBOTH/ START/END/INDENT/JAVABOTHType of trimming
whatstringnullSet of characters to trim (Applicable only for START, END and BOTH)

* Different Types of trimming

TypeJava equivalent functionPython equivalent function
BOTH (default)String::strip()'...'.strip(what)
STARTString::stripLeading()'...'.lstrip(what)
ENDString::stripTrailing()'...'.rstrip(what)
INDENTString::stripIndent()N/A
JAVAString::trim()N/A

Examples

Input

Definition

Output

"  hello  "
"$$trim:$"
"hello"
"--hello--"
"$$trim(BOTH,-):$"
"hello"
"⚠️hello⚠️"
"$$trim(BOTH,⚠️):$"
"hello"
"  hello  "
"$$trim(START):$"
"hello  "
"abcbchello  "
"$$trim(START,abc):$"
"hello  "
"  hello  "
"$$trim(END):$"
"  hello"
"  helloabcbc"
"$$trim(END,abc):$"
"  hello"
             <html> 
<body>
<p>Hello, world</p>
</body>
</html>
"$$trim(INDENT):$"
<html>
<body>
<p>Hello, world</p>
</body>
</html>