trim: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\| *arma3 * * *\| *([0-2]\.[0-9]{2}) * " to "|game1= arma3 |version1= $1 ")
m (Some wiki formatting)
 
(One intermediate revision by the same user not shown)
Line 8: Line 8:
|descr= Trims a [[String|string]].
|descr= Trims a [[String|string]].


|s1= [[trim]] stringValue
|s1= [[trim]] stringValue


|p1= stringValue: [[String]] - string to be trimmed. spaces, tabs and line returns are removed from both ends of ''stringValue''.
|p1= stringValue: [[String]] - string to be trimmed. spaces, tabs and line returns are removed from both ends of ''stringValue''.
Line 20: Line 20:
|p22= chars: [[String]] - list of characters to be trimmed
|p22= chars: [[String]] - list of characters to be trimmed


|p23= where: [[Number]] - Can be:
|p23= where: [[Number]] - can be:
* 0 - trim at the beginning (left) and the end (right)
* 0 - trim at the beginning (left) and the end (right)
* 1 - trim at the beginning (left)
* 1 - trim at the beginning (left)
Line 27: Line 27:
|r2= [[String]] - trimmed string
|r2= [[String]] - trimmed string


|x1= <code>[[trim]] " hello, how are you?  "; {{cc|returns "hello, how are you?"}}</code>
|x1= <sqf>trim " hello, how are you?  "; // returns "hello, how are you?"</sqf>


|x2= <code>"hewosentence!123" [[trim]] ["3e1o2hw", 0]; {{cc|returns "sentence!"}}</code>
|x2= <sqf>"hewosentence!123" trim ["3e1o2hw", 0]; // returns "sentence!"</sqf>


|seealso= [[select]]
|seealso= [[select]]
}}
}}

Latest revision as of 14:19, 5 May 2022

Hover & click on the images for description

Description

Description:
Trims a string.
Groups:
Strings

Syntax

Syntax:
trim stringValue
Parameters:
stringValue: String - string to be trimmed. spaces, tabs and line returns are removed from both ends of stringValue.
Return Value:
String - trimmed string

Alternative Syntax

Syntax:
string trim [chars, where]
Parameters:
string: String - string to be trimmed
chars: String - list of characters to be trimmed
where: Number - can be:
  • 0 - trim at the beginning (left) and the end (right)
  • 1 - trim at the beginning (left)
  • 2 - trim at the end (right)
Return Value:
String - trimmed string

Examples

Example 1:
trim " hello, how are you? "; // returns "hello, how are you?"
Example 2:
"hewosentence!123" trim ["3e1o2hw", 0]; // returns "sentence!"

Additional Information

See also:
select

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note