split_any / by
| Definition: |
sequence res = split_any(sequence source,
object delimiters=", \t|")
-- or -- sequence res = split_by(sequence source, integer l) |
| Description: |
The split_any() function splits a sequence on any of the specified delimiters into a number of sub-sequences.
The split_by() function splits a sequence into chucks of at most length l each. Returns a sequence, of sub-sequences of source. In the case of split_any, all instances of any of the specified delimiters are removed. |
| pwa/p2js: | Supported. |
| Comments: |
These functions may be applied to a string or any sequence.
Should delimiters be an atom or {atom} then split_any() behaves identically to split(), that is with no_empty=true and no limit. Prior to version 0.8.3, this routine had a confusing, unhelpfully defaulted, and incorrectly documented "no_empty" parameter, which always needed setting to true, along with an equally dubious "limit" that also never found any use. |
| Examples: |
s = split_any("{one,two,three}","{,}")
-- Output:
-- {"one","two","three"}
for i=1 to 10 do
?split_by(tagset(i),3)
end for
-- Output:
-- {{1}}
-- {{1,2}}
-- {{1,2,3}}
-- {{1,2,3},{4}}
-- {{1,2,3},{4,5}}
-- {{1,2,3},{4,5,6}}
-- {{1,2,3},{4,5,6},{7}}
-- {{1,2,3},{4,5,6},{7,8}}
-- {{1,2,3},{4,5,6},{7,8,9}}
-- {{1,2,3},{4,5,6},{7,8,9},{10}}
|
| Implementation: | See builtins\psplit.e (an autoinclude) for details of the actual implementation. |
| See Also: | join, flatten, columnize, split, shorten |