re module is a unique string matching module of Python.
Many functions provided in this module are implemented based on regular expressions.
The module is handy, to use it, need to import re module at first.
prototype
parameters
pattern
: Separator, can be character or regular expression.
string
: String to split.
maxsplit
: Maximum number of split. default is 0, which means no limitation. if minus, means no split.
flags
: Used to control how regular expressions are matched.
examples
- split the input string by
space
and ,
, only do one time split.
- split the string by character.
- match multiple characters