Split all the strings in ss at any of the characters in chars. Example: >>> ss = ["a.string[0].with_separators"] >>> chars = list(".[]_") >>> split_multichar(ss, chars) ['a', 'string', '0', '', 'with', 'separators'] :param (list) ss: A list of strings.
(ss, chars)
| 391 | |
| 392 | |
| 393 | def split_multichar(ss, chars): |
| 394 | """ |
| 395 | Split all the strings in ss at any of the characters in chars. |
| 396 | Example: |
| 397 | |
| 398 | >>> ss = ["a.string[0].with_separators"] |
| 399 | >>> chars = list(".[]_") |
| 400 | >>> split_multichar(ss, chars) |
| 401 | ['a', 'string', '0', '', 'with', 'separators'] |
| 402 | |
| 403 | :param (list) ss: A list of strings. |
| 404 | :param (list) chars: Is a list of chars (note: not a string). |
| 405 | """ |
| 406 | if len(chars) == 0: |
| 407 | return ss |
| 408 | c = chars.pop() |
| 409 | ss = reduce(lambda x, y: x + y, map(lambda x: x.split(c), ss)) |
| 410 | return split_multichar(ss, chars) |
| 411 | |
| 412 | |
| 413 | def split_string_positions(ss): |
no test coverage detected