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 | string * explode(string str, string del) |
| 3 | bytes * explode(bytes str, bytes del) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 4 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 5 | DESCRIPTION |
| 6 | Return an array of strings, created when the string str is split |
| 7 | into substrings as divided by del. When given a byte sequence |
| 8 | returns an array of byte sequences in a similar fashion. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 9 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 10 | implode(explode(str, del), del) == str is always true. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 11 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 12 | EXAMPLES |
| 13 | function returns |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 14 | ------------------------------------------------------------------- |
| 15 | explode(" ab cd ef ", " ") ({ "", "ab", "cd", "ef", "" }) |
| 16 | explode("abc", "abc") ({ "", "" }) |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 17 | explode("", "") ({ "" }) |
| 18 | explode("", <whatever>) ({ "" }) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 19 | explode("abc", "xyz") ({ "abc" }) |
| 20 | explode("abc", "") ({ "a", "b", "c" }) |
| 21 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 22 | HISTORY |
| 23 | Date of change is unknown. |
| 24 | explode(" ab cd ef ", " ") formerly returned ({ "ab", "cd", "ef" }) |
| 25 | instead of ({ "", "ab", "cd", "ef", "" }), i. e. the empty strings |
| 26 | were ignored. The new behaviour is more consistent, because now |
| 27 | implode(explode(str, del), del) == str is always true. |
| 28 | Since 3.5.0 explode("","") returns ({""}), so it is guaranteed to |
| 29 | return a non-empty array. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 30 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 31 | SEE ALSO |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 32 | sscanf(E), extract(E), implode(E), regexplode(E) |