$$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
| Argument | Type | Values | Required / Default Value | Description |
|---|---|---|---|---|
| Input | string | Yes | String to trim | |
type | enum | BOTH/ START/END/INDENT/JAVA | BOTH | Type of trimming |
what | string | null | Set of characters to trim (Applicable only for START, END and BOTH) |
* Different Types of trimming
| Type | Java equivalent function | Python equivalent function |
|---|---|---|
BOTH (default) | String::strip() | '...'.strip(what) |
START | String::stripLeading() | '...'.lstrip(what) |
END | String::stripTrailing() | '...'.rstrip(what) |
INDENT | String::stripIndent() | N/A |
JAVA | String::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>