mirror of
https://github.com/python/cpython.git
synced 2025-11-02 19:12:55 +00:00
Added thread unsafety warning. Added optional retain arg to split.
This commit is contained in:
parent
7c2fdda0b3
commit
6076ea51e2
2 changed files with 12 additions and 2 deletions
|
|
@ -4,6 +4,8 @@
|
||||||
This module defines a number of functions useful for working with
|
This module defines a number of functions useful for working with
|
||||||
regular expressions (see built-in module \code{regex}).
|
regular expressions (see built-in module \code{regex}).
|
||||||
|
|
||||||
|
Warning: these functions are not thread-safe.
|
||||||
|
|
||||||
\renewcommand{\indexsubitem}{(in module regsub)}
|
\renewcommand{\indexsubitem}{(in module regsub)}
|
||||||
\begin{funcdesc}{sub}{pat\, repl\, str}
|
\begin{funcdesc}{sub}{pat\, repl\, str}
|
||||||
Replace the first occurrence of pattern \var{pat} in string
|
Replace the first occurrence of pattern \var{pat} in string
|
||||||
|
|
@ -21,10 +23,13 @@ when not adjacent to a previous match, so e.g.
|
||||||
\code{gsub('', '-', 'abc')} returns \code{'-a-b-c-'}.
|
\code{gsub('', '-', 'abc')} returns \code{'-a-b-c-'}.
|
||||||
\end{funcdesc}
|
\end{funcdesc}
|
||||||
|
|
||||||
\begin{funcdesc}{split}{str\, pat}
|
\begin{funcdesc}{split}{str\, pat\optional{\, retain}}
|
||||||
Split the string \var{str} in fields separated by delimiters matching
|
Split the string \var{str} in fields separated by delimiters matching
|
||||||
the pattern \var{pat}, and return a list containing the fields. Only
|
the pattern \var{pat}, and return a list containing the fields. Only
|
||||||
non-empty matches for the pattern are considered, so e.g.
|
non-empty matches for the pattern are considered, so e.g.
|
||||||
\code{split('a:b', ':*')} returns \code{['a', 'b']} and
|
\code{split('a:b', ':*')} returns \code{['a', 'b']} and
|
||||||
\code{split('abc', '')} returns \code{['abc']}.
|
\code{split('abc', '')} returns \code{['abc']}.
|
||||||
|
If the optional \var{retain} argument is true, the separators are also
|
||||||
|
inserted in the list, so e.g. \code{split('a:::b', ':*', 1)} returns
|
||||||
|
\code{['a', ':::', 'b']}.
|
||||||
\end{funcdesc}
|
\end{funcdesc}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
This module defines a number of functions useful for working with
|
This module defines a number of functions useful for working with
|
||||||
regular expressions (see built-in module \code{regex}).
|
regular expressions (see built-in module \code{regex}).
|
||||||
|
|
||||||
|
Warning: these functions are not thread-safe.
|
||||||
|
|
||||||
\renewcommand{\indexsubitem}{(in module regsub)}
|
\renewcommand{\indexsubitem}{(in module regsub)}
|
||||||
\begin{funcdesc}{sub}{pat\, repl\, str}
|
\begin{funcdesc}{sub}{pat\, repl\, str}
|
||||||
Replace the first occurrence of pattern \var{pat} in string
|
Replace the first occurrence of pattern \var{pat} in string
|
||||||
|
|
@ -21,10 +23,13 @@ when not adjacent to a previous match, so e.g.
|
||||||
\code{gsub('', '-', 'abc')} returns \code{'-a-b-c-'}.
|
\code{gsub('', '-', 'abc')} returns \code{'-a-b-c-'}.
|
||||||
\end{funcdesc}
|
\end{funcdesc}
|
||||||
|
|
||||||
\begin{funcdesc}{split}{str\, pat}
|
\begin{funcdesc}{split}{str\, pat\optional{\, retain}}
|
||||||
Split the string \var{str} in fields separated by delimiters matching
|
Split the string \var{str} in fields separated by delimiters matching
|
||||||
the pattern \var{pat}, and return a list containing the fields. Only
|
the pattern \var{pat}, and return a list containing the fields. Only
|
||||||
non-empty matches for the pattern are considered, so e.g.
|
non-empty matches for the pattern are considered, so e.g.
|
||||||
\code{split('a:b', ':*')} returns \code{['a', 'b']} and
|
\code{split('a:b', ':*')} returns \code{['a', 'b']} and
|
||||||
\code{split('abc', '')} returns \code{['abc']}.
|
\code{split('abc', '')} returns \code{['abc']}.
|
||||||
|
If the optional \var{retain} argument is true, the separators are also
|
||||||
|
inserted in the list, so e.g. \code{split('a:::b', ':*', 1)} returns
|
||||||
|
\code{['a', ':::', 'b']}.
|
||||||
\end{funcdesc}
|
\end{funcdesc}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue