MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1 | SYNOPSIS |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 2 | #include <strings.h> |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 3 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame] | 4 | 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 User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 8 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame] | 9 | DESCRIPTION |
| 10 | Remove all leading and trailing characters <ch> from the string |
| 11 | <s> and return the new string. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 12 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame] | 13 | <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 User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 15 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame] | 16 | <where> can be used to modify where the characters are removed: |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 17 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame] | 18 | 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 User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 21 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame] | 22 | EXAMPLES |
| 23 | trim(" 1234 ") --> "1234" |
| 24 | trim(" 1234 ", TRIM_RIGHT) --> " 1234" |
| 25 | trim(" 1234 ", TRIM_BOTH, " 1") --> "234" |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 26 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame] | 27 | HISTORY |
| 28 | Introduced in LDMud 3.2.7. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 29 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame] | 30 | SEE ALSO |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 31 | regreplace(E) |