From Clomosy Docs

No edit summary
No edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
function Trim(const Text String):String;
<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert">
function Trim(const S: string): string;
</div>


The Trim function removes blank and control characters (such as line feed) from the start and end of a string.<br>
Trims leading and trailing spaces and control characters from a string.<br>
Trim removes leading and trailing spaces and control characters from the given string S.<br>


Use '''TrimLeft''' or '''TrimRight''' to limit the operation to just one end of the string.<br>
Use '''TrimLeft''' or '''TrimRight''' to limit the operation to just one end of the string.<br>


'''Example:'''<br>
<b>Example</b><br>
'''const'''
  textValue = '      Letters    ';<br>
'''begin'''<br>
  ShowMessage('/'+TrimLeft(textValue)+'/');
  ShowMessage('/'+TrimRight(textValue)+'/');
  ShowMessage('/'+Trim(textValue)+'/');<br>
'''end;'''


'''Output:'''<br>
<pre>
const
  textValue = '     Letters    ';
{
  ShowMessage('/'+TrimLeft(textValue)+'/');
  ShowMessage('/'+TrimRight(textValue)+'/');
  ShowMessage('/'+Trim(textValue)+'/');
}
</pre>
 
<b>Output:</b><br>


<gallery widths="150px" heights="300px" align="center" mode="nolines">
<gallery widths="150px" heights="300px" align="center" mode="nolines">
Line 21: Line 27:
File: TrimScreen.png | ''Trim Screen''
File: TrimScreen.png | ''Trim Screen''
</gallery>
</gallery>
<h2> See Also </h2>
* [[System_Library#String_Functions | String Functions]]
{{#seo:|title=Trim Using in Clomosy - Clomosy Docs}}
{{#seo:|description=Trim removes leading and trailing spaces and control characters from a string, ensuring clean text for further processing.}}

Latest revision as of 13:53, 24 December 2024

Trims leading and trailing spaces and control characters from a string.
Trim removes leading and trailing spaces and control characters from the given string S.

Use TrimLeft or TrimRight to limit the operation to just one end of the string.

Example

const
  textValue = '      Letters     ';
{
  ShowMessage('/'+TrimLeft(textValue)+'/');
  ShowMessage('/'+TrimRight(textValue)+'/');
  ShowMessage('/'+Trim(textValue)+'/');
}

Output:

See Also