Split the source string by the occurrences of the pattern, returning a list containing the resulting substrings. If capturing parentheses are used in pattern, then the text of all groups in the pattern are also returned as part of the resulting list. If maxsplit is nonzero, at most
(pattern, string, *args, maxsplit=_zero_sentinel, flags=_zero_sentinel)
| 241 | subn.__text_signature__ = '(pattern, repl, string, count=0, flags=0)' |
| 242 | |
| 243 | def split(pattern, string, *args, maxsplit=_zero_sentinel, flags=_zero_sentinel): |
| 244 | """Split the source string by the occurrences of the pattern, |
| 245 | returning a list containing the resulting substrings. If |
| 246 | capturing parentheses are used in pattern, then the text of all |
| 247 | groups in the pattern are also returned as part of the resulting |
| 248 | list. If maxsplit is nonzero, at most maxsplit splits occur, |
| 249 | and the remainder of the string is returned as the final element |
| 250 | of the list.""" |
| 251 | if args: |
| 252 | if maxsplit is not _zero_sentinel: |
| 253 | raise TypeError("split() got multiple values for argument 'maxsplit'") |
| 254 | maxsplit, *args = args |
| 255 | if args: |
| 256 | if flags is not _zero_sentinel: |
| 257 | raise TypeError("split() got multiple values for argument 'flags'") |
| 258 | flags, *args = args |
| 259 | if args: |
| 260 | raise TypeError("split() takes from 2 to 4 positional arguments " |
| 261 | "but %d were given" % (4 + len(args))) |
| 262 | |
| 263 | import warnings |
| 264 | warnings.warn( |
| 265 | "'maxsplit' is passed as positional argument", |
| 266 | DeprecationWarning, stacklevel=2 |
| 267 | ) |
| 268 | |
| 269 | return _compile(pattern, flags).split(string, maxsplit) |
| 270 | split.__text_signature__ = '(pattern, string, maxsplit=0, flags=0)' |
| 271 | |
| 272 | def findall(pattern, string, flags=0): |
searching dependent graphs…