blob: c14e6c08989ec84724ca7ef282cf3f66882aed4d [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001SYNOPSIS
Zesstrad59c3892019-11-28 20:53:39 +01002 #include <strings.h>
MG Mud User88f12472016-06-24 23:31:02 +02003
Zesstra715ec202025-07-09 22:18:31 +02004 string trim(string s)
5 string trim(string s, int where)
6 string trim(string s, int where, int ch)
7 string trim(string s, int where, string ch)
MG Mud User88f12472016-06-24 23:31:02 +02008
Zesstra715ec202025-07-09 22:18:31 +02009DESCRIPTION
10 Remove all leading and trailing characters <ch> from the string
11 <s> and return the new string.
MG Mud User88f12472016-06-24 23:31:02 +020012
Zesstra715ec202025-07-09 22:18:31 +020013 <ch> may be given as a single character, or a string of characters.
14 If <ch> is not given, it defaults to the whitespace " \t".
MG Mud User88f12472016-06-24 23:31:02 +020015
Zesstra715ec202025-07-09 22:18:31 +020016 <where> can be used to modify where the characters are removed:
MG Mud User88f12472016-06-24 23:31:02 +020017
Zesstra715ec202025-07-09 22:18:31 +020018 TRIM_LEFT (1): remove the leading characters
19 TRIM_RIGHT (2): remove the trailing characters
20 TRIM_BOTH (3 or 0): remove both leading and trailing characters
MG Mud User88f12472016-06-24 23:31:02 +020021
Zesstra715ec202025-07-09 22:18:31 +020022EXAMPLES
23 trim(" 1234 ") --> "1234"
24 trim(" 1234 ", TRIM_RIGHT) --> " 1234"
25 trim(" 1234 ", TRIM_BOTH, " 1") --> "234"
MG Mud User88f12472016-06-24 23:31:02 +020026
Zesstra715ec202025-07-09 22:18:31 +020027HISTORY
28 Introduced in LDMud 3.2.7.
MG Mud User88f12472016-06-24 23:31:02 +020029
Zesstra715ec202025-07-09 22:18:31 +020030SEE ALSO
MG Mud User88f12472016-06-24 23:31:02 +020031 regreplace(E)