FCF 2.0 development in progress...
> > > >
[News] [Packages API] [Downloads] [Donate to the project] [Contacts]

fcf.trim() function

string fcf.trim(string a_str, string|false|[string|false] a_delimiter = [false])

Package: fcf-framework-core

File: fcf-framework-core:fcf.js

Available from version: 2.0.2

Removes the specified characters from the beginning and end of a string

Arguments

string a_str
- Source string

string|false|[string|false] a_delimiter = [false]
- An array of characters to delete, or a single character string. If the array element is false, characters with code <= 32 are removed.
Result
string
- Result string

Example: Default mode

let newString = fcf.trim(` test string `); console.log(`"${newString}"`);

Output:

"test string"

Example: Single delimiter

let newString = fcf.trim(`/path/file/`, "/"); console.log(`"${newString}"`);

Output:

"path/file"

Example: Multiple delimiter

let newString = fcf.trim(` / \\ path/file/ / \\ `, ["/","\\", false]); console.log(`"${newString}"`);

Output:

"path/file"