StrTrimChar

Removes leading and trailing unwanted characters from a text string.

Syntax:

StrTrimChar(string, trim-chars[, flags])

Parameters:

(s) string: a string with unwanted characters at the beginning and/or end

(s) trim-chars: a string containing one or more unwanted characters

(i) flags: (optional) specifies where unwanted characters will be removed, see below

Returns:

(s) string devoid of leading and/or trailing unwanted characters, depending on flag value.

 

This function removes unwanted characters from the beginning and end of a text string.

 

Flags

value

meaning

1

Remove unwanted characters from left-hand side of string

2

Remove unwanted characters from right-hand side of string

3

Remove unwanted characters from both sides of string.

Default action if value not specified.

Example:
  ; Some text.
  hamlet = $"
To be, or not to be, that is the question::
Whether tis nobler in the mind to suffer
The slings and arrows of outrageous fortune
Or to take arms against a sea of troubles
And by opposing end them...
$"
  ; Remove the ellipsis and first and last
  ; line-feeds that may have leading spaces
  ; depending on whether your editor uses
  ; line-feeds or carriage-returns &
  ; line-feeds to end each line.
  lenbefore = StrLen(Hamlet)
  trimchars = " .":@lf ; Note space.
  trimmed = StrTrimChar(Hamlet, trimchars)
  lenafter = StrLen(Trimmed)
  
  lendif = lenbefore - lenafter
  
  Pause("This Can Be About 5 to 7 Removed", "Characters removed ":lendif)

 
See Also:

StrInsert, StrFill, StrFix, StrLen, StrOverlay, StrTrim