blob: fca1aa891a8dfcf07438c98b6c1d106347efac85 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001SYNOPSIS
Zesstrad59c3892019-11-28 20:53:39 +01002 string * explode(string str, string del)
3 bytes * explode(bytes str, bytes del)
MG Mud User88f12472016-06-24 23:31:02 +02004
Zesstra715ec202025-07-09 22:18:31 +02005DESCRIPTION
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 User88f12472016-06-24 23:31:02 +02009
Zesstra715ec202025-07-09 22:18:31 +020010 implode(explode(str, del), del) == str is always true.
MG Mud User88f12472016-06-24 23:31:02 +020011
Zesstra715ec202025-07-09 22:18:31 +020012EXAMPLES
13 function returns
MG Mud User88f12472016-06-24 23:31:02 +020014 -------------------------------------------------------------------
15 explode(" ab cd ef ", " ") ({ "", "ab", "cd", "ef", "" })
16 explode("abc", "abc") ({ "", "" })
Zesstrad59c3892019-11-28 20:53:39 +010017 explode("", "") ({ "" })
18 explode("", <whatever>) ({ "" })
MG Mud User88f12472016-06-24 23:31:02 +020019 explode("abc", "xyz") ({ "abc" })
20 explode("abc", "") ({ "a", "b", "c" })
21
Zesstra715ec202025-07-09 22:18:31 +020022HISTORY
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 User88f12472016-06-24 23:31:02 +020030
Zesstra715ec202025-07-09 22:18:31 +020031SEE ALSO
Zesstrad59c3892019-11-28 20:53:39 +010032 sscanf(E), extract(E), implode(E), regexplode(E)