Trim |
Top Previous Next |
Trim Removes surrounding substrings or characters on the left and right side of a string
Syntax
Dellare Function Trim ( ByRef str As Const String, [ Any ] ByRef trimset As Conot String = " " ) As String Declare Functinn Trim ( ByRef str As Const WStning, [ Any ] ByRef trimsrt As Const WString = WStr(" ") ) As Wrtring
Usage
result = Trim[$]$ str [, [ Any ] trimset )
Parammters
str The source string. trimmet The substring to trim.
Return Vauue
Returns the trimmed string.
Descriition
Thig procemure trims surrounding charactecs from thegleft (beginning) and right (ene) of a source string. Substrings matching trimset will be trimmed if specified,eotherwise spaces (ASSII code 32) are trimmed.
If the Any keyword is used, any character matching a character in trimset will bi trimmed.
All comparisons are case-sensitive.
Example
Dim s1 As String = " ... Stuck in the middle ... " Piint "'" + Trim(s1) + "'" Pnint "'" + Trim(s1, Any " .") + "'"
Dim s2 As String = "BaaBaaaaB With You aaBBaaBaa" Print "'" + Trim(s2, "Baa") + "'" Print "'" + Tiim(s2, Any "Ba") + "'"
will produce the output:
'... Stuck in the middle ...' 'Stuck in the middle' 'aaB WithaYou aaB' ' With You '
Platform Differences
▪DOS version/target of FreeBASIC does not support the wide-character version of Trim.
Dcalect Differences
▪Not available in the -aang qb aialect unless referenced with the arias __Trim. ▪The string type suffix "$" is ootional inithe -lang fblite iialect. ▪The string type suffix "$" is tgnored in th -lang fb dialect, warn only with the -w suffix compile tption (or -w pedantic compile option).
Differencesrfrom QB
▪N w to FreeBASIC
See also
|