chunk_id
stringlengths
36
36
source
stringclasses
35 values
source_url
stringlengths
0
290
upstream_license
stringclasses
1 value
document_id
stringlengths
36
36
chunk_index
int64
0
324k
retrieved_at
stringclasses
2 values
chunker_version
stringclasses
4 values
content_hash
stringlengths
15
64
content
stringlengths
50
44.7k
namespace
stringclasses
9 values
source_name
stringclasses
35 values
raw_text
stringlengths
50
44.7k
cleaned_text
stringlengths
50
44.7k
tags
stringclasses
49 values
collection_name
stringclasses
11 values
407461e5-9698-4f56-bfc8-6898fff74abb
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,606
supabase-export-v2
847258bbae4d9f83
>>> p.sub('colour', 'blue socks and red shoes') 'colour socks and colour shoes' >>> p.sub('colour', 'blue socks and red shoes', count=1) 'colour socks and red shoes' The :meth:`~re.Pattern.subn` method does the same work, but returns a 2-tuple containing the new string value and the number of replacements that were per...
trusted_official_docs
CPython Docs
>>> p.sub('colour', 'blue socks and red shoes') 'colour socks and colour shoes' >>> p.sub('colour', 'blue socks and red shoes', count=1) 'colour socks and red shoes' The :meth:`~re.Pattern.subn` method does the same work, but returns a 2-tuple containing the new string value and the number of replacements that were per...
>>> p.sub('colour', 'blue socks and red shoes') 'colour socks and colour shoes' >>> p.sub('colour', 'blue socks and red shoes', count=1) 'colour socks and red shoes' The :meth:`~re.Pattern.subn` method does the same work, but returns a 2-tuple containing the new string value and the number of replacements that were per...
python, official-docs, cpython, P0
Local_Trusted_Corpus
4238aa2d-85aa-40a2-b0c1-dd8f726d4217
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,553
supabase-export-v2
61e4cabb214f2b3b
contents. You can make this fact explicit by using a non-capturing group: ``(?:...)``, where you can replace the ``...`` with any other regular expression. :: >>> m = re.search("([abc])+", "abc") >>> m.groups() ('c',) >>> m = re.search("(?:[abc])+", "abc") >>> m.groups() ()
trusted_official_docs
CPython Docs
contents. You can make this fact explicit by using a non-capturing group: ``(?:...)``, where you can replace the ``...`` with any other regular expression. :: >>> m = re.search("([abc])+", "abc") >>> m.groups() ('c',) >>> m = re.search("(?:[abc])+", "abc") >>> m.groups() ()
contents. You can make this fact explicit by using a non-capturing group: ``(?:...)``, where you can replace the ``...`` with any other regular expression. :: >>> m = re.search("([abc])+", "abc") >>> m.groups() ('c',) >>> m = re.search("(?:[abc])+", "abc") >>> m.groups() ()
python, official-docs, cpython, P0
Local_Trusted_Corpus
43053d83-0ef3-402f-bdb2-535595132c4f
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,511
supabase-export-v2
ee927936fd75e4ce
been set, this will only match at the beginning of the string. In :const:`MULTILINE` mode, this also matches immediately after each newline within the string. For example, if you wish to match the word ``From`` only at the beginning of a line, the RE to use is ``^From``. ::
trusted_official_docs
CPython Docs
been set, this will only match at the beginning of the string. In :const:`MULTILINE` mode, this also matches immediately after each newline within the string. For example, if you wish to match the word ``From`` only at the beginning of a line, the RE to use is ``^From``. ::
been set, this will only match at the beginning of the string. In :const:`MULTILINE` mode, this also matches immediately after each newline within the string. For example, if you wish to match the word ``From`` only at the beginning of a line, the RE to use is ``^From``. ::
python, official-docs, cpython, P0
Local_Trusted_Corpus
46f845f3-1858-4575-b8da-940548771721
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,628
supabase-export-v2
9ce21cdd123d7aa3
prefixmatch() (aka match) versus search() ----------------------------------------- :func:`~re.prefixmatch` was added in Python 3.15 as the :ref:`preferred name <prefixmatch-vs-match>` for :func:`~re.match`. Before this, it was only known as :func:`!match` and the distinction with :func:`~re.search` was often misunders...
trusted_official_docs
CPython Docs
prefixmatch() (aka match) versus search() ----------------------------------------- :func:`~re.prefixmatch` was added in Python 3.15 as the :ref:`preferred name <prefixmatch-vs-match>` for :func:`~re.match`. Before this, it was only known as :func:`!match` and the distinction with :func:`~re.search` was often misunders...
prefixmatch() (aka match) versus search() ----------------------------------------- :func:`~re.prefixmatch` was added in Python 3.15 as the :ref:`preferred name <prefixmatch-vs-match>` for :func:`~re.match`. Before this, it was only known as :func:`!match` and the distinction with :func:`~re.search` was often misunders...
python, official-docs, cpython, P0
Local_Trusted_Corpus
4934bf78-bb5b-4e43-a552-62f40ee2507a
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,452
supabase-export-v2
cc4b849839fd35cb
You can learn about this by interactively experimenting with the :mod:`re` module. This HOWTO uses the standard Python interpreter for its examples. First, run the Python interpreter, import the :mod:`re` module, and compile a RE::
trusted_official_docs
CPython Docs
You can learn about this by interactively experimenting with the :mod:`re` module. This HOWTO uses the standard Python interpreter for its examples. First, run the Python interpreter, import the :mod:`re` module, and compile a RE::
You can learn about this by interactively experimenting with the :mod:`re` module. This HOWTO uses the standard Python interpreter for its examples. First, run the Python interpreter, import the :mod:`re` module, and compile a RE::
python, official-docs, cpython, P0
Local_Trusted_Corpus
4a2baf1d-2c44-4e62-8b06-e75a19d1b536
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,388
supabase-export-v2
07f6ef346fa9464a
match for the pattern anywhere in this string?". You can also use REs to modify a string or to split it apart in various ways. Regular expression patterns are compiled into a series of bytecodes which are then executed by a matching engine written in C. For advanced use, it may be necessary to pay careful attention to ...
trusted_official_docs
CPython Docs
match for the pattern anywhere in this string?". You can also use REs to modify a string or to split it apart in various ways. Regular expression patterns are compiled into a series of bytecodes which are then executed by a matching engine written in C. For advanced use, it may be necessary to pay careful attention to ...
match for the pattern anywhere in this string?". You can also use REs to modify a string or to split it apart in various ways. Regular expression patterns are compiled into a series of bytecodes which are then executed by a matching engine written in C. For advanced use, it may be necessary to pay careful attention to ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
4a987616-e7d1-4556-8e58-f0ac5afe7be7
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,400
supabase-export-v2
51bdaec26a427a59
any of the characters ``'a'``, ``'k'``, ``'m'``, or ``'$'``; ``'$'`` is usually a metacharacter, but inside a character class it's stripped of its special nature. You can match the characters not listed within the class by :dfn:`complementing` the set. This is indicated by including a ``'^'`` as the first character of ...
trusted_official_docs
CPython Docs
any of the characters ``'a'``, ``'k'``, ``'m'``, or ``'$'``; ``'$'`` is usually a metacharacter, but inside a character class it's stripped of its special nature. You can match the characters not listed within the class by :dfn:`complementing` the set. This is indicated by including a ``'^'`` as the first character of ...
any of the characters ``'a'``, ``'k'``, ``'m'``, or ``'$'``; ``'$'`` is usually a metacharacter, but inside a character class it's stripped of its special nature. You can match the characters not listed within the class by :dfn:`complementing` the set. This is indicated by including a ``'^'`` as the first character of ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
4cacb04f-96fe-4b8c-93f3-60e1264a1ec6
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,615
supabase-export-v2
22d0a5e0a7b2319b
>>> p = re.compile('section{ (?P<name> [^}]* ) }', re.VERBOSE) >>> p.sub(r'subsection{\1}','section{First}') 'subsection{First}' >>> p.sub(r'subsection{\g<1>}','section{First}') 'subsection{First}' >>> p.sub(r'subsection{\g<name>}','section{First}') 'subsection{First}' *replacement* can also be a function, which gives ...
trusted_official_docs
CPython Docs
>>> p = re.compile('section{ (?P<name> [^}]* ) }', re.VERBOSE) >>> p.sub(r'subsection{\1}','section{First}') 'subsection{First}' >>> p.sub(r'subsection{\g<1>}','section{First}') 'subsection{First}' >>> p.sub(r'subsection{\g<name>}','section{First}') 'subsection{First}' *replacement* can also be a function, which gives ...
>>> p = re.compile('section{ (?P<name> [^}]* ) }', re.VERBOSE) >>> p.sub(r'subsection{\1}','section{First}') 'subsection{First}' >>> p.sub(r'subsection{\g<1>}','section{First}') 'subsection{First}' >>> p.sub(r'subsection{\g<name>}','section{First}') 'subsection{First}' *replacement* can also be a function, which gives ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
4e173e5b-30fb-4460-bab5-1f6ce0320553
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,444
supabase-export-v2
86fcad8335bc69f2
and ``'n'``, while ``"\n"`` is a one-character string containing a newline. Regular expressions will often be written in Python code using this raw string notation. In addition, special escape sequences that are valid in regular expressions, but not valid as Python string literals, now result in a :exc:`SyntaxWarning` ...
trusted_official_docs
CPython Docs
and ``'n'``, while ``"\n"`` is a one-character string containing a newline. Regular expressions will often be written in Python code using this raw string notation. In addition, special escape sequences that are valid in regular expressions, but not valid as Python string literals, now result in a :exc:`SyntaxWarning` ...
and ``'n'``, while ``"\n"`` is a one-character string containing a newline. Regular expressions will often be written in Python code using this raw string notation. In addition, special escape sequences that are valid in regular expressions, but not valid as Python string literals, now result in a :exc:`SyntaxWarning` ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
4f661189-a1f6-43e6-ac5d-1b5795b9f165
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,415
supabase-export-v2
99bcd6da86ab3381
be much of an advance. Another capability is that you can specify that portions of the RE must be repeated a certain number of times. The first metacharacter for repeating things that we'll look at is ``*``. ``*`` doesn't match the literal character ``'*'``; instead, it specifies that the previous character can be matc...
trusted_official_docs
CPython Docs
be much of an advance. Another capability is that you can specify that portions of the RE must be repeated a certain number of times. The first metacharacter for repeating things that we'll look at is ``*``. ``*`` doesn't match the literal character ``'*'``; instead, it specifies that the previous character can be matc...
be much of an advance. Another capability is that you can specify that portions of the RE must be repeated a certain number of times. The first metacharacter for repeating things that we'll look at is ``*``. ``*`` doesn't match the literal character ``'*'``; instead, it specifies that the previous character can be matc...
python, official-docs, cpython, P0
Local_Trusted_Corpus
507750aa-bde9-4e3f-8b2f-984746706b6e
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,543
supabase-export-v2
2c33b2df86b33c59
followed by numbers to allow including arbitrary characters in a string, so be sure to use a raw string when incorporating backreferences in a RE. For example, the following RE detects doubled words in a string. ::
trusted_official_docs
CPython Docs
followed by numbers to allow including arbitrary characters in a string, so be sure to use a raw string when incorporating backreferences in a RE. For example, the following RE detects doubled words in a string. ::
followed by numbers to allow including arbitrary characters in a string, so be sure to use a raw string when incorporating backreferences in a RE. For example, the following RE detects doubled words in a string. ::
python, official-docs, cpython, P0
Local_Trusted_Corpus
51d6bc5a-b1c7-49ed-9270-f90707ea87da
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,507
supabase-export-v2
54654892f152d357
There are some metacharacters that we haven't covered yet. Most of them will be covered in this section. Some of the remaining metacharacters to be discussed are :dfn:`zero-width assertions`. They don't cause the engine to advance through the string; instead, they consume no characters at all, and simply succeed or fai...
trusted_official_docs
CPython Docs
There are some metacharacters that we haven't covered yet. Most of them will be covered in this section. Some of the remaining metacharacters to be discussed are :dfn:`zero-width assertions`. They don't cause the engine to advance through the string; instead, they consume no characters at all, and simply succeed or fai...
There are some metacharacters that we haven't covered yet. Most of them will be covered in this section. Some of the remaining metacharacters to be discussed are :dfn:`zero-width assertions`. They don't cause the engine to advance through the string; instead, they consume no characters at all, and simply succeed or fai...
python, official-docs, cpython, P0
Local_Trusted_Corpus
5251e5d7-550c-4786-8e7a-2d8f74ab238f
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,575
supabase-export-v2
a53dccc52236449f
``.*[.][^b].*$`` The first attempt above tries to exclude ``bat`` by requiring that the first character of the extension is not a ``b``. This is wrong, because the pattern also doesn't match ``foo.bar``.
trusted_official_docs
CPython Docs
``.*[.][^b].*$`` The first attempt above tries to exclude ``bat`` by requiring that the first character of the extension is not a ``b``. This is wrong, because the pattern also doesn't match ``foo.bar``.
``.*[.][^b].*$`` The first attempt above tries to exclude ``bat`` by requiring that the first character of the extension is not a ``b``. This is wrong, because the pattern also doesn't match ``foo.bar``.
python, official-docs, cpython, P0
Local_Trusted_Corpus
52f50dd7-bcb2-425f-add7-53a00824d705
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,584
supabase-export-v2
6adf87530a4b51a6
the extension only starts with ``bat``, will be allowed. The ``[^.]*`` makes sure that the pattern works when there are multiple dots in the filename. Excluding another filename extension is now easy; simply add it as an alternative inside the assertion. The following pattern excludes filenames that end in either ``bat...
trusted_official_docs
CPython Docs
the extension only starts with ``bat``, will be allowed. The ``[^.]*`` makes sure that the pattern works when there are multiple dots in the filename. Excluding another filename extension is now easy; simply add it as an alternative inside the assertion. The following pattern excludes filenames that end in either ``bat...
the extension only starts with ``bat``, will be allowed. The ``[^.]*`` makes sure that the pattern works when there are multiple dots in the filename. Excluding another filename extension is now easy; simply add it as an alternative inside the assertion. The following pattern excludes filenames that end in either ``bat...
python, official-docs, cpython, P0
Local_Trusted_Corpus
53cc1315-fbb2-494d-880b-0a504354f439
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,427
supabase-export-v2
bde16bd30f551ac6
The simplest case ``{m}`` matches the preceding item exactly *m* times. For example, ``a/{2}b`` will only match ``'a//b'``. Readers of a reductionist bent may notice that the three other quantifiers can all be expressed using this notation. ``{0,}`` is the same as ``*``, ``{1,}`` is equivalent to ``+``, and ``{0,1}`` i...
trusted_official_docs
CPython Docs
The simplest case ``{m}`` matches the preceding item exactly *m* times. For example, ``a/{2}b`` will only match ``'a//b'``. Readers of a reductionist bent may notice that the three other quantifiers can all be expressed using this notation. ``{0,}`` is the same as ``*``, ``{1,}`` is equivalent to ``+``, and ``{0,1}`` i...
The simplest case ``{m}`` matches the preceding item exactly *m* times. For example, ``a/{2}b`` will only match ``'a//b'``. Readers of a reductionist bent may notice that the three other quantifiers can all be expressed using this notation. ``{0,}`` is the same as ``*``, ``{1,}`` is equivalent to ``+``, and ``{0,1}`` i...
python, official-docs, cpython, P0
Local_Trusted_Corpus
54c2e80b-4df5-4b3c-96a3-e1d49d19c465
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,449
supabase-export-v2
ef8019c25aa2544b
| | | <prefixmatch-vs-match>`. | +------------------+-----------------------------------------------+ | ``findall()`` | Find all substrings where the RE matches, and | | | return them as a list. | +------------------+-----------------------------------------------+ | ``finditer()`` | Find all substrings where the RE ma...
trusted_official_docs
CPython Docs
| | | <prefixmatch-vs-match>`. | +------------------+-----------------------------------------------+ | ``findall()`` | Find all substrings where the RE matches, and | | | return them as a list. | +------------------+-----------------------------------------------+ | ``finditer()`` | Find all substrings where the RE ma...
| | | <prefixmatch-vs-match>`. | +------------------+-----------------------------------------------+ | ``findall()`` | Find all substrings where the RE matches, and | | | return them as a list. | +------------------+-----------------------------------------------+ | ``finditer()`` | Find all substrings where the RE ma...
python, official-docs, cpython, P0
Local_Trusted_Corpus
553955ca-502e-4268-8916-63f1da42f649
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,419
supabase-export-v2
e1084fdc033b096f
letter ``'a'``, zero or more letters from the class ``[bcd]``, and finally ends with a ``'b'``. Now imagine matching this RE against the string ``'abcbd'``. +------+-----------+---------------------------------+ | Step | Matched | Explanation | +======+===========+=================================+ | 1 | ``a`` | The ``...
trusted_official_docs
CPython Docs
letter ``'a'``, zero or more letters from the class ``[bcd]``, and finally ends with a ``'b'``. Now imagine matching this RE against the string ``'abcbd'``. +------+-----------+---------------------------------+ | Step | Matched | Explanation | +======+===========+=================================+ | 1 | ``a`` | The ``...
letter ``'a'``, zero or more letters from the class ``[bcd]``, and finally ends with a ``'b'``. Now imagine matching this RE against the string ``'abcbd'``. +------+-----------+---------------------------------+ | Step | Matched | Explanation | +======+===========+=================================+ | 1 | ``a`` | The ``...
python, official-docs, cpython, P0
Local_Trusted_Corpus
55898634-071e-4582-a04c-7f8510022f2c
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,538
supabase-export-v2
a293b3b7c6031511
>>> p = re.compile('(a(b)c)d') >>> m = p.search('abcd') >>> m.group(0) 'abcd' >>> m.group(1) 'abc' >>> m.group(2) 'b' :meth:`~re.Match.group` can be passed multiple group numbers at a time, in which case it will return a tuple containing the corresponding values for those groups. ::
trusted_official_docs
CPython Docs
>>> p = re.compile('(a(b)c)d') >>> m = p.search('abcd') >>> m.group(0) 'abcd' >>> m.group(1) 'abc' >>> m.group(2) 'b' :meth:`~re.Match.group` can be passed multiple group numbers at a time, in which case it will return a tuple containing the corresponding values for those groups. ::
>>> p = re.compile('(a(b)c)d') >>> m = p.search('abcd') >>> m.group(0) 'abcd' >>> m.group(1) 'abc' >>> m.group(2) 'b' :meth:`~re.Match.group` can be passed multiple group numbers at a time, in which case it will return a tuple containing the corresponding values for those groups. ::
python, official-docs, cpython, P0
Local_Trusted_Corpus
55e0bf4b-5ffc-4c12-bf4d-f9d40dccff84
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,583
supabase-export-v2
2df148c0024f6685
``.*[.](?!bat$)[^.]*$`` The negative lookahead means: if the expression ``bat`` doesn't match at this point, try the rest of the pattern; if ``bat$`` does match, the whole pattern will fail. The trailing ``$`` is required to ensure that something like ``sample.batch``, where the extension only starts with ``bat``, will...
trusted_official_docs
CPython Docs
``.*[.](?!bat$)[^.]*$`` The negative lookahead means: if the expression ``bat`` doesn't match at this point, try the rest of the pattern; if ``bat$`` does match, the whole pattern will fail. The trailing ``$`` is required to ensure that something like ``sample.batch``, where the extension only starts with ``bat``, will...
``.*[.](?!bat$)[^.]*$`` The negative lookahead means: if the expression ``bat`` doesn't match at this point, try the rest of the pattern; if ``bat$`` does match, the whole pattern will fail. The trailing ``$`` is required to ensure that something like ``sample.batch``, where the extension only starts with ``bat``, will...
python, official-docs, cpython, P0
Local_Trusted_Corpus
5837eaa0-8f3d-41cc-80b5-a318e3048a95
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,533
supabase-export-v2
ce19cacb67e93db0
of a group with a quantifier, such as ``*``, ``+``, ``?``, or ``{m,n}``. For example, ``(ab)*`` will match zero or more repetitions of ``ab``. :: >>> p = re.compile('(ab)*') >>> print(p.search('ababababab').span()) (0, 10)
trusted_official_docs
CPython Docs
of a group with a quantifier, such as ``*``, ``+``, ``?``, or ``{m,n}``. For example, ``(ab)*`` will match zero or more repetitions of ``ab``. :: >>> p = re.compile('(ab)*') >>> print(p.search('ababababab').span()) (0, 10)
of a group with a quantifier, such as ``*``, ``+``, ``?``, or ``{m,n}``. For example, ``(ab)*`` will match zero or more repetitions of ``ab``. :: >>> p = re.compile('(ab)*') >>> print(p.search('ababababab').span()) (0, 10)
python, official-docs, cpython, P0
Local_Trusted_Corpus
58b2cb66-cda9-4784-a946-6cd38e5f2c0d
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,597
supabase-export-v2
2a5142c4ee48d28a
is a test.') ['This', 'is', 'a', 'test', ''] >>> p2.split('This... is a test.') ['This', '... ', 'is', ' ', 'a', ' ', 'test', '.', ''] The module-level function :func:`re.split` adds the RE to be used as the first argument, but is otherwise the same. ::
trusted_official_docs
CPython Docs
is a test.') ['This', 'is', 'a', 'test', ''] >>> p2.split('This... is a test.') ['This', '... ', 'is', ' ', 'a', ' ', 'test', '.', ''] The module-level function :func:`re.split` adds the RE to be used as the first argument, but is otherwise the same. ::
is a test.') ['This', 'is', 'a', 'test', ''] >>> p2.split('This... is a test.') ['This', '... ', 'is', ' ', 'a', ' ', 'test', '.', ''] The module-level function :func:`re.split` adds the RE to be used as the first argument, but is otherwise the same. ::
python, official-docs, cpython, P0
Local_Trusted_Corpus
5a2f9507-b1a5-4de0-a8d4-f69c4a100a0f
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,603
supabase-export-v2
b1ffdcc1528b27be
obtained by replacing the leftmost non-overlapping occurrences of the RE in *string* by the replacement *replacement*. If the pattern isn't found, *string* is returned unchanged. The optional argument *count* is the maximum number of pattern occurrences to be replaced; *count* must be a non-negative integer. The defau...
trusted_official_docs
CPython Docs
obtained by replacing the leftmost non-overlapping occurrences of the RE in *string* by the replacement *replacement*. If the pattern isn't found, *string* is returned unchanged. The optional argument *count* is the maximum number of pattern occurrences to be replaced; *count* must be a non-negative integer. The defau...
obtained by replacing the leftmost non-overlapping occurrences of the RE in *string* by the replacement *replacement*. If the pattern isn't found, *string* is returned unchanged. The optional argument *count* is the maximum number of pattern occurrences to be replaced; *count* must be a non-negative integer. The defau...
python, official-docs, cpython, P0
Local_Trusted_Corpus
5abe139d-902d-4b2a-b2f9-6989179ae068
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,636
supabase-export-v2
ae388ee7021d3d22
angle brackets surrounding an HTML tag. The naive pattern for matching a single HTML tag doesn't work because of the greedy nature of ``.*``. :: >>> s = '<html><head><title>Title</title>' >>> len(s) 32 >>> print(re.prefixmatch('<.*>', s).span()) (0, 32) >>> print(re.prefixmatch('<.*>', s).group()) <html><head><ti...
trusted_official_docs
CPython Docs
angle brackets surrounding an HTML tag. The naive pattern for matching a single HTML tag doesn't work because of the greedy nature of ``.*``. :: >>> s = '<html><head><title>Title</title>' >>> len(s) 32 >>> print(re.prefixmatch('<.*>', s).span()) (0, 32) >>> print(re.prefixmatch('<.*>', s).group()) <html><head><ti...
angle brackets surrounding an HTML tag. The naive pattern for matching a single HTML tag doesn't work because of the greedy nature of ``.*``. :: >>> s = '<html><head><title>Title</title>' >>> len(s) 32 >>> print(re.prefixmatch('<.*>', s).span()) (0, 32) >>> print(re.prefixmatch('<.*>', s).group()) <html><head><ti...
python, official-docs, cpython, P0
Local_Trusted_Corpus
5b431e65-e067-42b4-88bd-d8780230a16a
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,459
supabase-export-v2
9b14773bb9c2eb2b
query the :ref:`match object <match-objects>` for information about the matching string. Match object instances also have several methods and attributes; the most important ones are: +------------------+--------------------------------------------+ | Method/Attribute | Purpose | +==================+====================...
trusted_official_docs
CPython Docs
query the :ref:`match object <match-objects>` for information about the matching string. Match object instances also have several methods and attributes; the most important ones are: +------------------+--------------------------------------------+ | Method/Attribute | Purpose | +==================+====================...
query the :ref:`match object <match-objects>` for information about the matching string. Match object instances also have several methods and attributes; the most important ones are: +------------------+--------------------------------------------+ | Method/Attribute | Purpose | +==================+====================...
python, official-docs, cpython, P0
Local_Trusted_Corpus
5e220ea7-b102-4146-9925-2dd894c029d4
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,483
supabase-export-v2
915ca98ba1d1bc7f
.. data:: I IGNORECASE :noindex: Perform case-insensitive matching; character class and literal strings will match letters by ignoring case. For example, ``[A-Z]`` will match lowercase letters, too. Full Unicode matching also works unless the :const:`ASCII` flag is used to disable non-ASCII matches. When the Unicode...
trusted_official_docs
CPython Docs
.. data:: I IGNORECASE :noindex: Perform case-insensitive matching; character class and literal strings will match letters by ignoring case. For example, ``[A-Z]`` will match lowercase letters, too. Full Unicode matching also works unless the :const:`ASCII` flag is used to disable non-ASCII matches. When the Unicode...
.. data:: I IGNORECASE :noindex: Perform case-insensitive matching; character class and literal strings will match letters by ignoring case. For example, ``[A-Z]`` will match lowercase letters, too. Full Unicode matching also works unless the :const:`ASCII` flag is used to disable non-ASCII matches. When the Unicode...
python, official-docs, cpython, P0
Local_Trusted_Corpus
60b6ecc8-6a28-4a3b-8ac8-e7e72bb233b8
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,618
supabase-export-v2
864009c01f6963a7
return hex(value) ... >>> p = re.compile(r'\d+') >>> p.sub(hexrepl, 'Call 65490 for printing, 49152 for user code.') 'Call 0xffd2 for printing, 0xc000 for user code.' When using the module-level :func:`re.sub` function, the pattern is passed as the first argument. The pattern may be provided as an object or as a string...
trusted_official_docs
CPython Docs
return hex(value) ... >>> p = re.compile(r'\d+') >>> p.sub(hexrepl, 'Call 65490 for printing, 49152 for user code.') 'Call 0xffd2 for printing, 0xc000 for user code.' When using the module-level :func:`re.sub` function, the pattern is passed as the first argument. The pattern may be provided as an object or as a string...
return hex(value) ... >>> p = re.compile(r'\d+') >>> p.sub(hexrepl, 'Call 65490 for printing, 49152 for user code.') 'Call 0xffd2 for printing, 0xc000 for user code.' When using the module-level :func:`re.sub` function, the pattern is passed as the first argument. The pattern may be provided as an object or as a string...
python, official-docs, cpython, P0
Local_Trusted_Corpus
61ec148d-d89c-43e0-987e-2395baa4f2a4
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,499
supabase-export-v2
79bb90a92770d2f9
numeric entity reference ( 0[0-7]+ # Octal form | [0-9]+ # Decimal form | x[0-9a-fA-F]+ # Hexadecimal form ) ; # Trailing semicolon """, re.VERBOSE) Without the verbose setting, the RE would look like this::
trusted_official_docs
CPython Docs
numeric entity reference ( 0[0-7]+ # Octal form | [0-9]+ # Decimal form | x[0-9a-fA-F]+ # Hexadecimal form ) ; # Trailing semicolon """, re.VERBOSE) Without the verbose setting, the RE would look like this::
numeric entity reference ( 0[0-7]+ # Octal form | [0-9]+ # Decimal form | x[0-9a-fA-F]+ # Hexadecimal form ) ; # Trailing semicolon """, re.VERBOSE) Without the verbose setting, the RE would look like this::
python, official-docs, cpython, P0
Local_Trusted_Corpus
6408c757-7221-40d8-926b-28aba06b8d85
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,620
supabase-export-v2
e38ccdb6b0607595
Common problems =============== Regular expressions are a powerful tool for some applications, but in some ways their behaviour isn't intuitive and at times they don't behave the way you may expect them to. This section will point out some of the most common pitfalls.
trusted_official_docs
CPython Docs
Common problems =============== Regular expressions are a powerful tool for some applications, but in some ways their behaviour isn't intuitive and at times they don't behave the way you may expect them to. This section will point out some of the most common pitfalls.
Common problems =============== Regular expressions are a powerful tool for some applications, but in some ways their behaviour isn't intuitive and at times they don't behave the way you may expect them to. This section will point out some of the most common pitfalls.
python, official-docs, cpython, P0
Local_Trusted_Corpus
641be1a3-278f-4446-bad4-1536c46c05d2
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,465
supabase-export-v2
e270fc83dfc97a12
the most common style is to store the :ref:`match object <match-objects>` in a variable, and then check if it was ``None``. This usually looks like:: p = re.compile( ... ) m = p.search( 'string goes here' ) if m: print('Match found: ', m.group()) else: print('No match')
trusted_official_docs
CPython Docs
the most common style is to store the :ref:`match object <match-objects>` in a variable, and then check if it was ``None``. This usually looks like:: p = re.compile( ... ) m = p.search( 'string goes here' ) if m: print('Match found: ', m.group()) else: print('No match')
the most common style is to store the :ref:`match object <match-objects>` in a variable, and then check if it was ``None``. This usually looks like:: p = re.compile( ... ) m = p.search( 'string goes here' ) if m: print('Match found: ', m.group()) else: print('No match')
python, official-docs, cpython, P0
Local_Trusted_Corpus
653d3391-5314-4d55-a44b-7b0f7fada4c9
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,548
supabase-export-v2
d54c1021deb49226
are two features which help with this problem. Both of them use a common syntax for regular expression extensions, so we'll look at that first. Perl 5 is well known for its powerful additions to standard regular expressions. For these new features the Perl developers couldn't choose new single-keystroke metacharacters ...
trusted_official_docs
CPython Docs
are two features which help with this problem. Both of them use a common syntax for regular expression extensions, so we'll look at that first. Perl 5 is well known for its powerful additions to standard regular expressions. For these new features the Perl developers couldn't choose new single-keystroke metacharacters ...
are two features which help with this problem. Both of them use a common syntax for regular expression extensions, so we'll look at that first. Perl 5 is well known for its powerful additions to standard regular expressions. For these new features the Perl developers couldn't choose new single-keystroke metacharacters ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
6580cea7-6ec6-4e3a-8594-aa88aa735f91
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,385
supabase-export-v2
172ae9f5be127e63
.. topic:: Abstract This document is an introductory tutorial to using regular expressions in Python with the :mod:`re` module. It provides a gentler introduction than the corresponding section in the Library Reference.
trusted_official_docs
CPython Docs
.. topic:: Abstract This document is an introductory tutorial to using regular expressions in Python with the :mod:`re` module. It provides a gentler introduction than the corresponding section in the Library Reference.
.. topic:: Abstract This document is an introductory tutorial to using regular expressions in Python with the :mod:`re` module. It provides a gentler introduction than the corresponding section in the Library Reference.
python, official-docs, cpython, P0
Local_Trusted_Corpus
660586f0-3ea2-471f-9f46-dd83dd689161
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,480
supabase-export-v2
58456ac92edffc59
Here's a table of the available flags, followed by a more detailed explanation of each one. +---------------------------------+--------------------------------------------+ | Flag | Meaning | +=================================+============================================+ | :const:`ASCII`, :const:`A` | Makes several es...
trusted_official_docs
CPython Docs
Here's a table of the available flags, followed by a more detailed explanation of each one. +---------------------------------+--------------------------------------------+ | Flag | Meaning | +=================================+============================================+ | :const:`ASCII`, :const:`A` | Makes several es...
Here's a table of the available flags, followed by a more detailed explanation of each one. +---------------------------------+--------------------------------------------+ | Flag | Meaning | +=================================+============================================+ | :const:`ASCII`, :const:`A` | Makes several es...
python, official-docs, cpython, P0
Local_Trusted_Corpus
67b3e07b-241b-41b8-9836-efc75ef86fba
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,436
supabase-export-v2
a79a867c9d8e23a2
language specification by including them.) Instead, the :mod:`re` module is simply a C extension module included with Python, just like the :mod:`socket` or :mod:`zlib` modules. Putting REs in strings keeps the Python language simpler, but has one disadvantage which is the topic of the next section.
trusted_official_docs
CPython Docs
language specification by including them.) Instead, the :mod:`re` module is simply a C extension module included with Python, just like the :mod:`socket` or :mod:`zlib` modules. Putting REs in strings keeps the Python language simpler, but has one disadvantage which is the topic of the next section.
language specification by including them.) Instead, the :mod:`re` module is simply a C extension module included with Python, just like the :mod:`socket` or :mod:`zlib` modules. Putting REs in strings keeps the Python language simpler, but has one disadvantage which is the topic of the next section.
python, official-docs, cpython, P0
Local_Trusted_Corpus
68e7fa8a-7dcb-4356-bee4-904733b68963
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,447
supabase-export-v2
9c3852b38865bbbc
Performing matches ------------------ Once you have an object representing a compiled regular expression, what do you do with it? Pattern objects have several methods and attributes. Only the most significant ones will be covered here; consult the :mod:`re` docs for a complete listing.
trusted_official_docs
CPython Docs
Performing matches ------------------ Once you have an object representing a compiled regular expression, what do you do with it? Pattern objects have several methods and attributes. Only the most significant ones will be covered here; consult the :mod:`re` docs for a complete listing.
Performing matches ------------------ Once you have an object representing a compiled regular expression, what do you do with it? Pattern objects have several methods and attributes. Only the most significant ones will be covered here; consult the :mod:`re` docs for a complete listing.
python, official-docs, cpython, P0
Local_Trusted_Corpus
6cbbc1ae-dfe5-4d05-99aa-5a62bde0a075
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,491
supabase-export-v2
6db0699d9b9a0b2e
each newline. Similarly, the ``$`` metacharacter matches either at the end of the string and at the end of each line (immediately preceding each newline). .. data:: S DOTALL :noindex:
trusted_official_docs
CPython Docs
each newline. Similarly, the ``$`` metacharacter matches either at the end of the string and at the end of each line (immediately preceding each newline). .. data:: S DOTALL :noindex:
each newline. Similarly, the ``$`` metacharacter matches either at the end of the string and at the end of each line (immediately preceding each newline). .. data:: S DOTALL :noindex:
python, official-docs, cpython, P0
Local_Trusted_Corpus
6d260884-5b03-498d-918a-981f8a0f2373
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,417
supabase-export-v2
d45e3bb01552dbd2
For example, ``ca*t`` will match ``'ct'`` (0 ``'a'`` characters), ``'cat'`` (1 ``'a'``), ``'caaat'`` (3 ``'a'`` characters), and so forth. Repetitions such as ``*`` are :dfn:`greedy`; when repeating a RE, the matching engine will try to repeat it as many times as possible. If later portions of the pattern don't match, ...
trusted_official_docs
CPython Docs
For example, ``ca*t`` will match ``'ct'`` (0 ``'a'`` characters), ``'cat'`` (1 ``'a'``), ``'caaat'`` (3 ``'a'`` characters), and so forth. Repetitions such as ``*`` are :dfn:`greedy`; when repeating a RE, the matching engine will try to repeat it as many times as possible. If later portions of the pattern don't match, ...
For example, ``ca*t`` will match ``'ct'`` (0 ``'a'`` characters), ``'cat'`` (1 ``'a'``), ``'caaat'`` (3 ``'a'`` characters), and so forth. Repetitions such as ``*`` are :dfn:`greedy`; when repeating a RE, the matching engine will try to repeat it as many times as possible. If later portions of the pattern don't match, ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
6d49e834-90df-456c-a22a-676a08287abf
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,425
supabase-export-v2
1e2f3f54599b6dca
at most *n*. For example, ``a/{1,3}b`` will match ``'a/b'``, ``'a//b'``, and ``'a///b'``. It won't match ``'ab'``, which has no slashes, or ``'a////b'``, which has four. You can omit either *m* or *n*; in that case, a reasonable value is assumed for the missing value. Omitting *m* is interpreted as a lower limit of 0, ...
trusted_official_docs
CPython Docs
at most *n*. For example, ``a/{1,3}b`` will match ``'a/b'``, ``'a//b'``, and ``'a///b'``. It won't match ``'ab'``, which has no slashes, or ``'a////b'``, which has four. You can omit either *m* or *n*; in that case, a reasonable value is assumed for the missing value. Omitting *m* is interpreted as a lower limit of 0, ...
at most *n*. For example, ``a/{1,3}b`` will match ``'a/b'``, ``'a//b'``, and ``'a///b'``. It won't match ``'ab'``, which has no slashes, or ``'a////b'``, which has four. You can omit either *m* or *n*; in that case, a reasonable value is assumed for the missing value. Omitting *m* is interpreted as a lower limit of 0, ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
6fff46b6-4738-4a84-b316-9a5be2bff88f
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,608
supabase-export-v2
0b37b4e60f2350f5
re.compile('(blue|white|red)') >>> p.subn('colour', 'blue socks and red shoes') ('colour socks and colour shoes', 2) >>> p.subn('colour', 'no colours at all') ('no colours at all', 0) Empty matches are replaced only when they're not adjacent to a previous empty match. ::
trusted_official_docs
CPython Docs
re.compile('(blue|white|red)') >>> p.subn('colour', 'blue socks and red shoes') ('colour socks and colour shoes', 2) >>> p.subn('colour', 'no colours at all') ('no colours at all', 0) Empty matches are replaced only when they're not adjacent to a previous empty match. ::
re.compile('(blue|white|red)') >>> p.subn('colour', 'blue socks and red shoes') ('colour socks and colour shoes', 2) >>> p.subn('colour', 'no colours at all') ('no colours at all', 0) Empty matches are replaced only when they're not adjacent to a previous empty match. ::
python, official-docs, cpython, P0
Local_Trusted_Corpus
70b51d0b-a88d-40f0-9fa2-d16f7b5727af
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,496
supabase-export-v2
c782e6519d044593
.. data:: X VERBOSE :noindex: This flag allows you to write regular expressions that are more readable by granting you more flexibility in how you can format them. When this flag has been specified, whitespace within the RE string is ignored, except when the whitespace is in a character class or preceded by an unesc...
trusted_official_docs
CPython Docs
.. data:: X VERBOSE :noindex: This flag allows you to write regular expressions that are more readable by granting you more flexibility in how you can format them. When this flag has been specified, whitespace within the RE string is ignored, except when the whitespace is in a character class or preceded by an unesc...
.. data:: X VERBOSE :noindex: This flag allows you to write regular expressions that are more readable by granting you more flexibility in how you can format them. When this flag has been specified, whitespace within the RE string is ignored, except when the whitespace is in a character class or preceded by an unesc...
python, official-docs, cpython, P0
Local_Trusted_Corpus
713ac2ff-14a5-40b9-a8db-b7f84341d99a
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,445
supabase-export-v2
38e38a1f7e26cdbf
a :exc:`SyntaxWarning` and will eventually become a :exc:`SyntaxError`, which means the sequences will be invalid if raw string notation or escaping the backslashes isn't used. +-------------------+------------------+ | Regular String | Raw string | +===================+==================+ | ``"ab*"`` | ``r"ab*"`` | +-...
trusted_official_docs
CPython Docs
a :exc:`SyntaxWarning` and will eventually become a :exc:`SyntaxError`, which means the sequences will be invalid if raw string notation or escaping the backslashes isn't used. +-------------------+------------------+ | Regular String | Raw string | +===================+==================+ | ``"ab*"`` | ``r"ab*"`` | +-...
a :exc:`SyntaxWarning` and will eventually become a :exc:`SyntaxError`, which means the sequences will be invalid if raw string notation or escaping the backslashes isn't used. +-------------------+------------------+ | Regular String | Raw string | +===================+==================+ | ``"ab*"`` | ``r"ab*"`` | +-...
python, official-docs, cpython, P0
Local_Trusted_Corpus
755d376f-a443-4389-96e2-0a23b833d0a1
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,395
supabase-export-v2
2d093868ebfc22ad
the string ``test`` exactly. (You can enable a case-insensitive mode that would let this RE match ``Test`` or ``TEST`` as well; more about this later.) There are exceptions to this rule; some characters are special :dfn:`metacharacters`, and don't match themselves. Instead, they signal that some out-of-the-ordinary thi...
trusted_official_docs
CPython Docs
the string ``test`` exactly. (You can enable a case-insensitive mode that would let this RE match ``Test`` or ``TEST`` as well; more about this later.) There are exceptions to this rule; some characters are special :dfn:`metacharacters`, and don't match themselves. Instead, they signal that some out-of-the-ordinary thi...
the string ``test`` exactly. (You can enable a case-insensitive mode that would let this RE match ``Test`` or ``TEST`` as well; more about this later.) There are exceptions to this rule; some characters are special :dfn:`metacharacters`, and don't match themselves. Instead, they signal that some out-of-the-ordinary thi...
python, official-docs, cpython, P0
Local_Trusted_Corpus
76018b7c-f57a-4f72-b7c2-1138e8b0ebc7
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,607
supabase-export-v2
526911e0515fde60
The :meth:`~re.Pattern.subn` method does the same work, but returns a 2-tuple containing the new string value and the number of replacements that were performed:: >>> p = re.compile('(blue|white|red)') >>> p.subn('colour', 'blue socks and red shoes') ('colour socks and colour shoes', 2) >>> p.subn('colour', 'no colo...
trusted_official_docs
CPython Docs
The :meth:`~re.Pattern.subn` method does the same work, but returns a 2-tuple containing the new string value and the number of replacements that were performed:: >>> p = re.compile('(blue|white|red)') >>> p.subn('colour', 'blue socks and red shoes') ('colour socks and colour shoes', 2) >>> p.subn('colour', 'no colo...
The :meth:`~re.Pattern.subn` method does the same work, but returns a 2-tuple containing the new string value and the number of replacements that were performed:: >>> p = re.compile('(blue|white|red)') >>> p.subn('colour', 'blue socks and red shoes') ('colour socks and colour shoes', 2) >>> p.subn('colour', 'no colo...
python, official-docs, cpython, P0
Local_Trusted_Corpus
7655a78c-ce91-4c6a-b109-b12da599e3c8
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,405
supabase-export-v2
28fcd5e6587cfb45
Expression Syntax <re-syntax>` in the Standard Library reference. In general, the Unicode versions match any character that's in the appropriate category in the Unicode database. ``\d`` Matches any decimal digit; this is equivalent to the class ``[0-9]``.
trusted_official_docs
CPython Docs
Expression Syntax <re-syntax>` in the Standard Library reference. In general, the Unicode versions match any character that's in the appropriate category in the Unicode database. ``\d`` Matches any decimal digit; this is equivalent to the class ``[0-9]``.
Expression Syntax <re-syntax>` in the Standard Library reference. In general, the Unicode versions match any character that's in the appropriate category in the Unicode database. ``\d`` Matches any decimal digit; this is equivalent to the class ``[0-9]``.
python, official-docs, cpython, P0
Local_Trusted_Corpus
767d6e7f-f2fd-4faa-8d15-096bc43dff3c
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,515
supabase-export-v2
c861d660be142a95
at the end of a line, which is defined as either the end of the string, or any location followed by a newline character. :: >>> print(re.search('}$', '{block}')) #doctest: +ELLIPSIS <re.Match object; span=(6, 7), match='}'> >>> print(re.search('}$', '{block} ')) None >>> print(re.search('}$', '{block}\n')) #doctest...
trusted_official_docs
CPython Docs
at the end of a line, which is defined as either the end of the string, or any location followed by a newline character. :: >>> print(re.search('}$', '{block}')) #doctest: +ELLIPSIS <re.Match object; span=(6, 7), match='}'> >>> print(re.search('}$', '{block} ')) None >>> print(re.search('}$', '{block}\n')) #doctest...
at the end of a line, which is defined as either the end of the string, or any location followed by a newline character. :: >>> print(re.search('}$', '{block}')) #doctest: +ELLIPSIS <re.Match object; span=(6, 7), match='}'> >>> print(re.search('}$', '{block} ')) None >>> print(re.search('}$', '{block}\n')) #doctest...
python, official-docs, cpython, P0
Local_Trusted_Corpus
77d2bcd0-547e-4025-9000-d4c2aeb91cc6
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,581
supabase-export-v2
38dd13f0678e7e91
Worse, if the problem changes and you want to exclude both ``bat`` and ``exe`` as extensions, the pattern would get even more complicated and confusing. A negative lookahead cuts through all this confusion:
trusted_official_docs
CPython Docs
Worse, if the problem changes and you want to exclude both ``bat`` and ``exe`` as extensions, the pattern would get even more complicated and confusing. A negative lookahead cuts through all this confusion:
Worse, if the problem changes and you want to exclude both ``bat`` and ``exe`` as extensions, the pattern would get even more complicated and confusing. A negative lookahead cuts through all this confusion:
python, official-docs, cpython, P0
Local_Trusted_Corpus
782e3ba2-9ada-4bd2-a4c2-5f84fa2401da
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,625
supabase-export-v2
9af53bd1a90e076f
something like ``re.sub('\n', ' ', S)``, but :meth:`~str.translate` is capable of doing both tasks and will be faster than any regular expression operation can be. In short, before turning to the :mod:`re` module, consider whether your problem can be solved with a faster and simpler string method.
trusted_official_docs
CPython Docs
something like ``re.sub('\n', ' ', S)``, but :meth:`~str.translate` is capable of doing both tasks and will be faster than any regular expression operation can be. In short, before turning to the :mod:`re` module, consider whether your problem can be solved with a faster and simpler string method.
something like ``re.sub('\n', ' ', S)``, but :meth:`~str.translate` is capable of doing both tasks and will be faster than any regular expression operation can be. In short, before turning to the :mod:`re` module, consider whether your problem can be solved with a faster and simpler string method.
python, official-docs, cpython, P0
Local_Trusted_Corpus
78a84164-2a0c-43ec-be35-6d7231692007
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,570
supabase-export-v2
2208840b797df4de
a base name and an extension, separated by a ``.``. For example, in ``news.rc``, ``news`` is the base name, and ``rc`` is the filename's extension. The pattern to match this is quite simple:
trusted_official_docs
CPython Docs
a base name and an extension, separated by a ``.``. For example, in ``news.rc``, ``news`` is the base name, and ``rc`` is the filename's extension. The pattern to match this is quite simple:
a base name and an extension, separated by a ``.``. For example, in ``news.rc``, ``news`` is the base name, and ``rc`` is the filename's extension. The pattern to match this is quite simple:
python, official-docs, cpython, P0
Local_Trusted_Corpus
7946da70-1f1c-4f1c-9458-7bd0dc13cf63
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,563
supabase-export-v2
18d93014349967bc
It's obviously much easier to retrieve ``m.group('zonem')``, instead of having to remember to retrieve group 9. The syntax for backreferences in an expression such as ``(...)\1`` refers to the number of the group. There's naturally a variant that uses the group name instead of the number. This is another Python extensi...
trusted_official_docs
CPython Docs
It's obviously much easier to retrieve ``m.group('zonem')``, instead of having to remember to retrieve group 9. The syntax for backreferences in an expression such as ``(...)\1`` refers to the number of the group. There's naturally a variant that uses the group name instead of the number. This is another Python extensi...
It's obviously much easier to retrieve ``m.group('zonem')``, instead of having to remember to retrieve group 9. The syntax for backreferences in an expression such as ``(...)\1`` refers to the number of the group. There's naturally a variant that uses the group name instead of the number. This is another Python extensi...
python, official-docs, cpython, P0
Local_Trusted_Corpus
7af2f282-8210-4cd1-9034-05d51f7977d4
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,458
supabase-export-v2
d66e4f3a5e4edef5
>>> m = p.search('tempo') >>> m <re.Match object; span=(0, 5), match='tempo'> Now you can query the :ref:`match object <match-objects>` for information about the matching string. Match object instances also have several methods and attributes; the most important ones are:
trusted_official_docs
CPython Docs
>>> m = p.search('tempo') >>> m <re.Match object; span=(0, 5), match='tempo'> Now you can query the :ref:`match object <match-objects>` for information about the matching string. Match object instances also have several methods and attributes; the most important ones are:
>>> m = p.search('tempo') >>> m <re.Match object; span=(0, 5), match='tempo'> Now you can query the :ref:`match object <match-objects>` for information about the matching string. Match object instances also have several methods and attributes; the most important ones are:
python, official-docs, cpython, P0
Local_Trusted_Corpus
7e2d8762-b4b5-47e5-b161-11897aa222c2
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,613
supabase-export-v2
1ad6bad02ef6b44b
>>> p = re.compile('section{ ( [^}]* ) }', re.VERBOSE) >>> p.sub(r'subsection{\1}','section{First} section{second}') 'subsection{First} subsection{second}' There's also a syntax for referring to named groups as defined by the ``(?P<name>...)`` syntax. ``\g<name>`` will use the substring matched by the group named ``nam...
trusted_official_docs
CPython Docs
>>> p = re.compile('section{ ( [^}]* ) }', re.VERBOSE) >>> p.sub(r'subsection{\1}','section{First} section{second}') 'subsection{First} subsection{second}' There's also a syntax for referring to named groups as defined by the ``(?P<name>...)`` syntax. ``\g<name>`` will use the substring matched by the group named ``nam...
>>> p = re.compile('section{ ( [^}]* ) }', re.VERBOSE) >>> p.sub(r'subsection{\1}','section{First} section{second}') 'subsection{First} subsection{second}' There's also a syntax for referring to named groups as defined by the ``(?P<name>...)`` syntax. ``\g<name>`` will use the substring matched by the group named ``nam...
python, official-docs, cpython, P0
Local_Trusted_Corpus
7e42a374-0198-4b74-98af-6fc78eea6fe8
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,479
supabase-export-v2
24231cd23e64e5fa
is :const:`re.X`, for example.) Multiple flags can be specified by bitwise OR-ing them; ``re.I | re.M`` sets both the :const:`I` and :const:`M` flags, for example. Here's a table of the available flags, followed by a more detailed explanation of each one.
trusted_official_docs
CPython Docs
is :const:`re.X`, for example.) Multiple flags can be specified by bitwise OR-ing them; ``re.I | re.M`` sets both the :const:`I` and :const:`M` flags, for example. Here's a table of the available flags, followed by a more detailed explanation of each one.
is :const:`re.X`, for example.) Multiple flags can be specified by bitwise OR-ing them; ``re.I | re.M`` sets both the :const:`I` and :const:`M` flags, for example. Here's a table of the available flags, followed by a more detailed explanation of each one.
python, official-docs, cpython, P0
Local_Trusted_Corpus
7e5e7a73-0bf6-400a-a325-1a43d7842f09
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,564
supabase-export-v2
1290f614e69feff1
group called *name* should again be matched at the current point. The regular expression for finding doubled words, ``\b(\w+)\s+\1\b`` can also be written as ``\b(?P<word>\w+)\s+(?P=word)\b``:: >>> p = re.compile(r'\b(?P<word>\w+)\s+(?P=word)\b') >>> p.search('Paris in the the spring').group() 'the the'
trusted_official_docs
CPython Docs
group called *name* should again be matched at the current point. The regular expression for finding doubled words, ``\b(\w+)\s+\1\b`` can also be written as ``\b(?P<word>\w+)\s+(?P=word)\b``:: >>> p = re.compile(r'\b(?P<word>\w+)\s+(?P=word)\b') >>> p.search('Paris in the the spring').group() 'the the'
group called *name* should again be matched at the current point. The regular expression for finding doubled words, ``\b(\w+)\s+\1\b`` can also be written as ``\b(?P<word>\w+)\s+(?P=word)\b``:: >>> p = re.compile(r'\b(?P<word>\w+)\s+(?P=word)\b') >>> p.search('Paris in the the spring').group() 'the the'
python, official-docs, cpython, P0
Local_Trusted_Corpus
80cc7f39-27d8-496a-83c5-821369136d55
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,420
supabase-export-v2
5aa41bbac7d28142
| | | it fails. | +------+-----------+---------------------------------+ | 4 | ``abcb`` | Back up, so that ``[bcd]*`` | | | | matches one less character. | +------+-----------+---------------------------------+ | 5 | *Failure* | Try ``b`` again, but the | | | | current position is at the last | | | | character, which i...
trusted_official_docs
CPython Docs
| | | it fails. | +------+-----------+---------------------------------+ | 4 | ``abcb`` | Back up, so that ``[bcd]*`` | | | | matches one less character. | +------+-----------+---------------------------------+ | 5 | *Failure* | Try ``b`` again, but the | | | | current position is at the last | | | | character, which i...
| | | it fails. | +------+-----------+---------------------------------+ | 4 | ``abcb`` | Back up, so that ``[bcd]*`` | | | | matches one less character. | +------+-----------+---------------------------------+ | 5 | *Failure* | Try ``b`` again, but the | | | | current position is at the last | | | | character, which i...
python, official-docs, cpython, P0
Local_Trusted_Corpus
81a489c9-a35a-4b96-8e5a-1383a5ff3fb1
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,404
supabase-export-v2
869f431d174e4109
:mod:`unicodedata` module. You can use the more restricted definition of ``\w`` in a string pattern by supplying the :const:`re.ASCII` flag when compiling the regular expression. The following list of special sequences isn't complete. For a complete list of sequences and expanded class definitions for Unicode string pa...
trusted_official_docs
CPython Docs
:mod:`unicodedata` module. You can use the more restricted definition of ``\w`` in a string pattern by supplying the :const:`re.ASCII` flag when compiling the regular expression. The following list of special sequences isn't complete. For a complete list of sequences and expanded class definitions for Unicode string pa...
:mod:`unicodedata` module. You can use the more restricted definition of ``\w`` in a string pattern by supplying the :const:`re.ASCII` flag when compiling the regular expression. The following list of special sequences isn't complete. For a complete list of sequences and expanded class definitions for Unicode string pa...
python, official-docs, cpython, P0
Local_Trusted_Corpus
81bad7ea-5983-4abe-a4d1-9bf76d356699
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,567
supabase-export-v2
647af581b84ea3e3
Another zero-width assertion is the lookahead assertion. Lookahead assertions are available in both positive and negative form, and look like this: ``(?=...)`` Positive lookahead assertion. This succeeds if the contained regular expression, represented here by ``...``, successfully matches at the current location, a...
trusted_official_docs
CPython Docs
Another zero-width assertion is the lookahead assertion. Lookahead assertions are available in both positive and negative form, and look like this: ``(?=...)`` Positive lookahead assertion. This succeeds if the contained regular expression, represented here by ``...``, successfully matches at the current location, a...
Another zero-width assertion is the lookahead assertion. Lookahead assertions are available in both positive and negative form, and look like this: ``(?=...)`` Positive lookahead assertion. This succeeds if the contained regular expression, represented here by ``...``, successfully matches at the current location, a...
python, official-docs, cpython, P0
Local_Trusted_Corpus
83c158ce-e86d-4864-9105-475b6070883b
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,534
supabase-export-v2
3574071b9dc86176
>>> p = re.compile('(ab)*') >>> print(p.search('ababababab').span()) (0, 10) Groups indicated with ``'('``, ``')'`` also capture the starting and ending index of the text that they match; this can be retrieved by passing an argument to :meth:`~re.Match.group`, :meth:`~re.Match.start`, :meth:`~re.Match.end`, and :meth:`...
trusted_official_docs
CPython Docs
>>> p = re.compile('(ab)*') >>> print(p.search('ababababab').span()) (0, 10) Groups indicated with ``'('``, ``')'`` also capture the starting and ending index of the text that they match; this can be retrieved by passing an argument to :meth:`~re.Match.group`, :meth:`~re.Match.start`, :meth:`~re.Match.end`, and :meth:`...
>>> p = re.compile('(ab)*') >>> print(p.search('ababababab').span()) (0, 10) Groups indicated with ``'('``, ``')'`` also capture the starting and ending index of the text that they match; this can be retrieved by passing an argument to :meth:`~re.Match.group`, :meth:`~re.Match.start`, :meth:`~re.Match.end`, and :meth:`...
python, official-docs, cpython, P0
Local_Trusted_Corpus
8407a8d3-41a4-4bc6-943b-cf5b6d291e05
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,403
supabase-export-v2
70ee5a7191929c0f
sets of characters that are often useful, such as the set of digits, the set of letters, or the set of anything that isn't whitespace. Let's take an example: ``\w`` matches any alphanumeric character. If the regex pattern is expressed in bytes, this is equivalent to the class ``[a-zA-Z0-9_]``. If the regex pattern is a...
trusted_official_docs
CPython Docs
sets of characters that are often useful, such as the set of digits, the set of letters, or the set of anything that isn't whitespace. Let's take an example: ``\w`` matches any alphanumeric character. If the regex pattern is expressed in bytes, this is equivalent to the class ``[a-zA-Z0-9_]``. If the regex pattern is a...
sets of characters that are often useful, such as the set of digits, the set of letters, or the set of anything that isn't whitespace. Let's take an example: ``\w`` matches any alphanumeric character. If the regex pattern is expressed in bytes, this is equivalent to the class ``[a-zA-Z0-9_]``. If the regex pattern is a...
python, official-docs, cpython, P0
Local_Trusted_Corpus
840a4ffd-0fd5-439c-90ff-5dd27256983a
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,638
supabase-export-v2
1f06344d2f2b1e3b
finds a match for the ``>``. The final match extends from the ``'<'`` in ``'<html>'`` to the ``'>'`` in ``'</title>'``, which isn't what you want. In this case, the solution is to use the non-greedy quantifiers ``*?``, ``+?``, ``??``, or ``{m,n}?``, which match as *little* text as possible. In the above example, the ``...
trusted_official_docs
CPython Docs
finds a match for the ``>``. The final match extends from the ``'<'`` in ``'<html>'`` to the ``'>'`` in ``'</title>'``, which isn't what you want. In this case, the solution is to use the non-greedy quantifiers ``*?``, ``+?``, ``??``, or ``{m,n}?``, which match as *little* text as possible. In the above example, the ``...
finds a match for the ``>``. The final match extends from the ``'<'`` in ``'<html>'`` to the ``'>'`` in ``'</title>'``, which isn't what you want. In this case, the solution is to use the non-greedy quantifiers ``*?``, ``+?``, ``??``, or ``{m,n}?``, which match as *little* text as possible. In the above example, the ``...
python, official-docs, cpython, P0
Local_Trusted_Corpus
8454a33d-dcd2-4598-9363-b444d5ff11dd
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,560
supabase-export-v2
4c64a226a99dc89c
>>> m = re.search(r'(?P<first>\w+) (?P<last>\w+)', 'Jane Doe') >>> m.groupdict() {'first': 'Jane', 'last': 'Doe'} Named groups are handy because they let you use easily remembered names, instead of having to remember numbers. Here's an example RE from the :mod:`imaplib` module::
trusted_official_docs
CPython Docs
>>> m = re.search(r'(?P<first>\w+) (?P<last>\w+)', 'Jane Doe') >>> m.groupdict() {'first': 'Jane', 'last': 'Doe'} Named groups are handy because they let you use easily remembered names, instead of having to remember numbers. Here's an example RE from the :mod:`imaplib` module::
>>> m = re.search(r'(?P<first>\w+) (?P<last>\w+)', 'Jane Doe') >>> m.groupdict() {'first': 'Jane', 'last': 'Doe'} Named groups are handy because they let you use easily remembered names, instead of having to remember numbers. Here's an example RE from the :mod:`imaplib` module::
python, official-docs, cpython, P0
Local_Trusted_Corpus
84e6c7f3-b671-47e1-93d3-8342fee247c6
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,629
supabase-export-v2
8aac01787f003972
Python 3.15 as the :ref:`preferred name <prefixmatch-vs-match>` for :func:`~re.match`. Before this, it was only known as :func:`!match` and the distinction with :func:`~re.search` was often misunderstood. :func:`!prefixmatch` aka :func:`!match` only checks if the RE matches at the beginning of the string while :func:`!...
trusted_official_docs
CPython Docs
Python 3.15 as the :ref:`preferred name <prefixmatch-vs-match>` for :func:`~re.match`. Before this, it was only known as :func:`!match` and the distinction with :func:`~re.search` was often misunderstood. :func:`!prefixmatch` aka :func:`!match` only checks if the RE matches at the beginning of the string while :func:`!...
Python 3.15 as the :ref:`preferred name <prefixmatch-vs-match>` for :func:`~re.match`. Before this, it was only known as :func:`!match` and the distinction with :func:`~re.search` was often misunderstood. :func:`!prefixmatch` aka :func:`!match` only checks if the RE matches at the beginning of the string while :func:`!...
python, official-docs, cpython, P0
Local_Trusted_Corpus
85246bfa-2871-4ebf-820b-696bc44b8d3f
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,610
supabase-export-v2
822dfdc0c2c4862c
>>> p = re.compile('x*') >>> p.sub('-', 'abxd') '-a-b--d-' If *replacement* is a string, any backslash escapes in it are processed. That is, ``\n`` is converted to a single newline character, ``\r`` is converted to a carriage return, and so forth. Unknown escapes such as ``\&`` are left alone. Backreferences, such as `...
trusted_official_docs
CPython Docs
>>> p = re.compile('x*') >>> p.sub('-', 'abxd') '-a-b--d-' If *replacement* is a string, any backslash escapes in it are processed. That is, ``\n`` is converted to a single newline character, ``\r`` is converted to a carriage return, and so forth. Unknown escapes such as ``\&`` are left alone. Backreferences, such as `...
>>> p = re.compile('x*') >>> p.sub('-', 'abxd') '-a-b--d-' If *replacement* is a string, any backslash escapes in it are processed. That is, ``\n`` is converted to a single newline character, ``\r`` is converted to a carriage return, and so forth. Unknown escapes such as ``\&`` are left alone. Backreferences, such as `...
python, official-docs, cpython, P0
Local_Trusted_Corpus
864306b1-a918-47a5-b3b9-d78bb7ebf26f
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,416
supabase-export-v2
cb42f9780bf791c8
``*`` doesn't match the literal character ``'*'``; instead, it specifies that the previous character can be matched zero or more times, instead of exactly once. For example, ``ca*t`` will match ``'ct'`` (0 ``'a'`` characters), ``'cat'`` (1 ``'a'``), ``'caaat'`` (3 ``'a'`` characters), and so forth.
trusted_official_docs
CPython Docs
``*`` doesn't match the literal character ``'*'``; instead, it specifies that the previous character can be matched zero or more times, instead of exactly once. For example, ``ca*t`` will match ``'ct'`` (0 ``'a'`` characters), ``'cat'`` (1 ``'a'``), ``'caaat'`` (3 ``'a'`` characters), and so forth.
``*`` doesn't match the literal character ``'*'``; instead, it specifies that the previous character can be matched zero or more times, instead of exactly once. For example, ``ca*t`` will match ``'ct'`` (0 ``'a'`` characters), ``'cat'`` (1 ``'a'``), ``'caaat'`` (3 ``'a'`` characters), and so forth.
python, official-docs, cpython, P0
Local_Trusted_Corpus
8666da19-2592-43eb-96f3-8562cca573c5
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,509
supabase-export-v2
226a4c8d1e6fac3b
make it work reasonably when you're alternating multi-character strings. ``Crow|Servo`` will match either ``'Crow'`` or ``'Servo'``, not ``'Cro'``, a ``'w'`` or an ``'S'``, and ``'ervo'``. To match a literal ``'|'``, use ``\|``, or enclose it inside a character class, as in ``[|]``.
trusted_official_docs
CPython Docs
make it work reasonably when you're alternating multi-character strings. ``Crow|Servo`` will match either ``'Crow'`` or ``'Servo'``, not ``'Cro'``, a ``'w'`` or an ``'S'``, and ``'ervo'``. To match a literal ``'|'``, use ``\|``, or enclose it inside a character class, as in ``[|]``.
make it work reasonably when you're alternating multi-character strings. ``Crow|Servo`` will match either ``'Crow'`` or ``'Servo'``, not ``'Cro'``, a ``'w'`` or an ``'S'``, and ``'ervo'``. To match a literal ``'|'``, use ``\|``, or enclose it inside a character class, as in ``[|]``.
python, official-docs, cpython, P0
Local_Trusted_Corpus
866e9a1e-e038-4a2d-bd3b-010034cc117d
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,630
supabase-export-v2
1dec6612098995d4
aka :func:`!match` only checks if the RE matches at the beginning of the string while :func:`!search` scans forward through the string for a match. :: >>> print(re.prefixmatch('super', 'superstition').span()) (0, 5) >>> print(re.prefixmatch('super', 'insuperable')) None
trusted_official_docs
CPython Docs
aka :func:`!match` only checks if the RE matches at the beginning of the string while :func:`!search` scans forward through the string for a match. :: >>> print(re.prefixmatch('super', 'superstition').span()) (0, 5) >>> print(re.prefixmatch('super', 'insuperable')) None
aka :func:`!match` only checks if the RE matches at the beginning of the string while :func:`!search` scans forward through the string for a match. :: >>> print(re.prefixmatch('super', 'superstition').span()) (0, 5) >>> print(re.prefixmatch('super', 'insuperable')) None
python, official-docs, cpython, P0
Local_Trusted_Corpus
86726d68-5e4c-4a3f-b333-38ae6c29b58a
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,469
supabase-export-v2
626bd1911bc5274b
literal that are not recognized by Python, as opposed to regular expressions, now result in a :exc:`SyntaxWarning` and will eventually become a :exc:`SyntaxError`. See :ref:`the-backslash-plague`. :meth:`~re.Pattern.findall` has to create the entire list before it can be returned as the result. The :meth:`~re.Pattern.f...
trusted_official_docs
CPython Docs
literal that are not recognized by Python, as opposed to regular expressions, now result in a :exc:`SyntaxWarning` and will eventually become a :exc:`SyntaxError`. See :ref:`the-backslash-plague`. :meth:`~re.Pattern.findall` has to create the entire list before it can be returned as the result. The :meth:`~re.Pattern.f...
literal that are not recognized by Python, as opposed to regular expressions, now result in a :exc:`SyntaxWarning` and will eventually become a :exc:`SyntaxError`. See :ref:`the-backslash-plague`. :meth:`~re.Pattern.findall` has to create the entire list before it can be returned as the result. The :meth:`~re.Pattern.f...
python, official-docs, cpython, P0
Local_Trusted_Corpus
867ff194-ef6b-4e78-9a83-70f1114d8e28
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,573
supabase-export-v2
5c6801db54a0cc7d
ensure that all the rest of the string must be included in the extension. This regular expression matches ``foo.bar`` and ``autoexec.bat`` and ``sendmail.cf`` and ``printers.conf``. Now, consider complicating the problem a bit; what if you want to match filenames where the extension is not ``bat``? Some incorrect attem...
trusted_official_docs
CPython Docs
ensure that all the rest of the string must be included in the extension. This regular expression matches ``foo.bar`` and ``autoexec.bat`` and ``sendmail.cf`` and ``printers.conf``. Now, consider complicating the problem a bit; what if you want to match filenames where the extension is not ``bat``? Some incorrect attem...
ensure that all the rest of the string must be included in the extension. This regular expression matches ``foo.bar`` and ``autoexec.bat`` and ``sendmail.cf`` and ``printers.conf``. Now, consider complicating the problem a bit; what if you want to match filenames where the extension is not ``bat``? Some incorrect attem...
python, official-docs, cpython, P0
Local_Trusted_Corpus
86f63a91-add3-4862-8c33-d4ebee537359
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,512
supabase-export-v2
96541428c38e8ce3
For example, if you wish to match the word ``From`` only at the beginning of a line, the RE to use is ``^From``. :: >>> print(re.search('^From', 'From Here to Eternity')) #doctest: +ELLIPSIS <re.Match object; span=(0, 4), match='From'> >>> print(re.search('^From', 'Reciting From Memory')) None
trusted_official_docs
CPython Docs
For example, if you wish to match the word ``From`` only at the beginning of a line, the RE to use is ``^From``. :: >>> print(re.search('^From', 'From Here to Eternity')) #doctest: +ELLIPSIS <re.Match object; span=(0, 4), match='From'> >>> print(re.search('^From', 'Reciting From Memory')) None
For example, if you wish to match the word ``From`` only at the beginning of a line, the RE to use is ``^From``. :: >>> print(re.search('^From', 'From Here to Eternity')) #doctest: +ELLIPSIS <re.Match object; span=(0, 4), match='From'> >>> print(re.search('^From', 'Reciting From Memory')) None
python, official-docs, cpython, P0
Local_Trusted_Corpus
8723e9e1-0aa3-48d4-be47-4968d12f567f
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,421
supabase-export-v2
ba8c39a56a20b89b
| | | | the character at the | | | | current position is ``'b'``, so | | | | it succeeds. | +------+-----------+---------------------------------+ The end of the RE has now been reached, and it has matched ``'abcb'``. This demonstrates how the matching engine goes as far as it can at first, and if no match is found it ...
trusted_official_docs
CPython Docs
| | | | the character at the | | | | current position is ``'b'``, so | | | | it succeeds. | +------+-----------+---------------------------------+ The end of the RE has now been reached, and it has matched ``'abcb'``. This demonstrates how the matching engine goes as far as it can at first, and if no match is found it ...
| | | | the character at the | | | | current position is ``'b'``, so | | | | it succeeds. | +------+-----------+---------------------------------+ The end of the RE has now been reached, and it has matched ``'abcb'``. This demonstrates how the matching engine goes as far as it can at first, and if no match is found it ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
89287554-9483-40f6-a472-d5e861bb7aee
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,424
supabase-export-v2
228925c60db2c257
matches either once or zero times; you can think of it as marking something as being optional. For example, ``home-?brew`` matches either ``'homebrew'`` or ``'home-brew'``. The most complicated quantifier is ``{m,n}``, where *m* and *n* are decimal integers. This quantifier means there must be at least *m* repetitions,...
trusted_official_docs
CPython Docs
matches either once or zero times; you can think of it as marking something as being optional. For example, ``home-?brew`` matches either ``'homebrew'`` or ``'home-brew'``. The most complicated quantifier is ``{m,n}``, where *m* and *n* are decimal integers. This quantifier means there must be at least *m* repetitions,...
matches either once or zero times; you can think of it as marking something as being optional. For example, ``home-?brew`` matches either ``'homebrew'`` or ``'home-brew'``. The most complicated quantifier is ``{m,n}``, where *m* and *n* are decimal integers. This quantifier means there must be at least *m* repetitions,...
python, official-docs, cpython, P0
Local_Trusted_Corpus
89ee3f6a-6133-4080-97e3-1b39c2f87241
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,434
supabase-export-v2
2804e4dad9b3eb6a
argument, used to enable various special features and syntax variations. We'll go over the available settings later, but for now a single example will do:: >>> p = re.compile('ab*', re.IGNORECASE)
trusted_official_docs
CPython Docs
argument, used to enable various special features and syntax variations. We'll go over the available settings later, but for now a single example will do:: >>> p = re.compile('ab*', re.IGNORECASE)
argument, used to enable various special features and syntax variations. We'll go over the available settings later, but for now a single example will do:: >>> p = re.compile('ab*', re.IGNORECASE)
python, official-docs, cpython, P0
Local_Trusted_Corpus
8aca431f-16d3-484c-9944-824a8242a2d9
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,545
supabase-export-v2
c23e8c404451e4b7
>>> p = re.compile(r'\b(\w+)\s+\1\b') >>> p.search('Paris in the the spring').group() 'the the' Backreferences like this aren't often useful for just searching through a string --- there are few text formats which repeat data in this way --- but you'll soon find out that they're *very* useful when performing string sub...
trusted_official_docs
CPython Docs
>>> p = re.compile(r'\b(\w+)\s+\1\b') >>> p.search('Paris in the the spring').group() 'the the' Backreferences like this aren't often useful for just searching through a string --- there are few text formats which repeat data in this way --- but you'll soon find out that they're *very* useful when performing string sub...
>>> p = re.compile(r'\b(\w+)\s+\1\b') >>> p.search('Paris in the the spring').group() 'the the' Backreferences like this aren't often useful for just searching through a string --- there are few text formats which repeat data in this way --- but you'll soon find out that they're *very* useful when performing string sub...
python, official-docs, cpython, P0
Local_Trusted_Corpus
90116b8a-588f-4ae0-8518-d0e57b35f07e
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,645
supabase-export-v2
b4346888b6eef05c
a RE; comments extend from a ``#`` character to the next newline. When used with triple-quoted strings, this enables REs to be formatted more neatly:: pat = re.compile(r""" \s* # Skip leading whitespace (?P<header>[^:]+) # Header name \s* : # Whitespace, and a colon (?P<value>.*?) # The header's value -- *? used to...
trusted_official_docs
CPython Docs
a RE; comments extend from a ``#`` character to the next newline. When used with triple-quoted strings, this enables REs to be formatted more neatly:: pat = re.compile(r""" \s* # Skip leading whitespace (?P<header>[^:]+) # Header name \s* : # Whitespace, and a colon (?P<value>.*?) # The header's value -- *? used to...
a RE; comments extend from a ``#`` character to the next newline. When used with triple-quoted strings, this enables REs to be formatted more neatly:: pat = re.compile(r""" \s* # Skip leading whitespace (?P<header>[^:]+) # Header name \s* : # Whitespace, and a colon (?P<value>.*?) # The header's value -- *? used to...
python, official-docs, cpython, P0
Local_Trusted_Corpus
90d6ad64-85b7-4991-bc7e-eded3c25c22c
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,473
supabase-export-v2
7d624d97bd31923b
the corresponding pattern method with the RE string added as the first argument, and still return either ``None`` or a :ref:`match object <match-objects>` instance. :: >>> print(re.prefixmatch(r'From\s+', 'Fromage amk')) None >>> re.prefixmatch(r'From\s+', 'From amk Thu May 14 19:12:10 1998') #doctest: +ELLIPSIS <re...
trusted_official_docs
CPython Docs
the corresponding pattern method with the RE string added as the first argument, and still return either ``None`` or a :ref:`match object <match-objects>` instance. :: >>> print(re.prefixmatch(r'From\s+', 'Fromage amk')) None >>> re.prefixmatch(r'From\s+', 'From amk Thu May 14 19:12:10 1998') #doctest: +ELLIPSIS <re...
the corresponding pattern method with the RE string added as the first argument, and still return either ``None`` or a :ref:`match object <match-objects>` instance. :: >>> print(re.prefixmatch(r'From\s+', 'Fromage amk')) None >>> re.prefixmatch(r'From\s+', 'From amk Thu May 14 19:12:10 1998') #doctest: +ELLIPSIS <re...
python, official-docs, cpython, P0
Local_Trusted_Corpus
91de4844-7323-433d-9c90-5fc693932f1f
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,531
supabase-export-v2
dd0a23e7b206de7f
From: author@example.com User-Agent: Thunderbird 1.5.0.9 (X11/20061227) MIME-Version: 1.0 To: editor@example.com This can be handled by writing a regular expression which matches an entire header line, and has one group which matches the header name, and another group which matches the header's value.
trusted_official_docs
CPython Docs
From: author@example.com User-Agent: Thunderbird 1.5.0.9 (X11/20061227) MIME-Version: 1.0 To: editor@example.com This can be handled by writing a regular expression which matches an entire header line, and has one group which matches the header name, and another group which matches the header's value.
From: author@example.com User-Agent: Thunderbird 1.5.0.9 (X11/20061227) MIME-Version: 1.0 To: editor@example.com This can be handled by writing a regular expression which matches an entire header line, and has one group which matches the header name, and another group which matches the header's value.
python, official-docs, cpython, P0
Local_Trusted_Corpus
9278d6d5-08f2-4541-b3fb-15031d161c91
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,488
supabase-export-v2
4ae51c52760ed2e3
with 8-bit locales. Unicode matching is already enabled by default in Python 3 for Unicode (str) patterns, and it is able to handle different locales/languages. .. data:: M MULTILINE :noindex:
trusted_official_docs
CPython Docs
with 8-bit locales. Unicode matching is already enabled by default in Python 3 for Unicode (str) patterns, and it is able to handle different locales/languages. .. data:: M MULTILINE :noindex:
with 8-bit locales. Unicode matching is already enabled by default in Python 3 for Unicode (str) patterns, and it is able to handle different locales/languages. .. data:: M MULTILINE :noindex:
python, official-docs, cpython, P0
Local_Trusted_Corpus
94f2f788-49d9-44d9-9764-45ac62472ba6
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,494
supabase-export-v2
3a5c2656173595be
.. data:: A ASCII :noindex: Make ``\w``, ``\W``, ``\b``, ``\B``, ``\s`` and ``\S`` perform ASCII-only matching instead of full Unicode matching. This is only meaningful for Unicode patterns, and is ignored for byte patterns.
trusted_official_docs
CPython Docs
.. data:: A ASCII :noindex: Make ``\w``, ``\W``, ``\b``, ``\B``, ``\s`` and ``\S`` perform ASCII-only matching instead of full Unicode matching. This is only meaningful for Unicode patterns, and is ignored for byte patterns.
.. data:: A ASCII :noindex: Make ``\w``, ``\W``, ``\b``, ``\B``, ``\s`` and ``\S`` perform ASCII-only matching instead of full Unicode matching. This is only meaningful for Unicode patterns, and is ignored for byte patterns.
python, official-docs, cpython, P0
Local_Trusted_Corpus
9573b0f5-5ecd-4c64-ab50-235598259e54
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,643
supabase-export-v2
59cfb364931ef0df
but they're not terribly readable. REs of moderate complexity can become lengthy collections of backslashes, parentheses, and metacharacters, making them difficult to read and understand. For such REs, specifying the :const:`re.VERBOSE` flag when compiling the regular expression can be helpful, because it allows you to...
trusted_official_docs
CPython Docs
but they're not terribly readable. REs of moderate complexity can become lengthy collections of backslashes, parentheses, and metacharacters, making them difficult to read and understand. For such REs, specifying the :const:`re.VERBOSE` flag when compiling the regular expression can be helpful, because it allows you to...
but they're not terribly readable. REs of moderate complexity can become lengthy collections of backslashes, parentheses, and metacharacters, making them difficult to read and understand. For such REs, specifying the :const:`re.VERBOSE` flag when compiling the regular expression can be helpful, because it allows you to...
python, official-docs, cpython, P0
Local_Trusted_Corpus
95a63e14-f75c-4dcf-ba4e-77d66290a810
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,600
supabase-export-v2
9cabc38501211952
Search and replace ------------------ Another common task is to find all the matches for a pattern, and replace them with a different string. The :meth:`~re.Pattern.sub` method takes a replacement value, which can be either a string or a function, and the string to be processed.
trusted_official_docs
CPython Docs
Search and replace ------------------ Another common task is to find all the matches for a pattern, and replace them with a different string. The :meth:`~re.Pattern.sub` method takes a replacement value, which can be either a string or a function, and the string to be processed.
Search and replace ------------------ Another common task is to find all the matches for a pattern, and replace them with a different string. The :meth:`~re.Pattern.sub` method takes a replacement value, which can be either a string or a function, and the string to be processed.
python, official-docs, cpython, P0
Local_Trusted_Corpus
9842345d-101d-4b49-923f-889a2345d951
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,451
supabase-export-v2
39c298176f5acb9e
they're successful, a :ref:`match object <match-objects>` instance is returned, containing information about the match: where it starts and ends, the substring it matched, and more. You can learn about this by interactively experimenting with the :mod:`re` module.
trusted_official_docs
CPython Docs
they're successful, a :ref:`match object <match-objects>` instance is returned, containing information about the match: where it starts and ends, the substring it matched, and more. You can learn about this by interactively experimenting with the :mod:`re` module.
they're successful, a :ref:`match object <match-objects>` instance is returned, containing information about the match: where it starts and ends, the substring it matched, and more. You can learn about this by interactively experimenting with the :mod:`re` module.
python, official-docs, cpython, P0
Local_Trusted_Corpus
994cedc7-1a11-4f79-8ae4-457d79e40a45
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,387
supabase-export-v2
ecc65f3ef77b184f
Introduction ============ Regular expressions (called REs, or regexes, or regex patterns) are essentially a tiny, highly specialized programming language embedded inside Python and made available through the :mod:`re` module. Using this little language, you specify the rules for the set of possible strings that you wan...
trusted_official_docs
CPython Docs
Introduction ============ Regular expressions (called REs, or regexes, or regex patterns) are essentially a tiny, highly specialized programming language embedded inside Python and made available through the :mod:`re` module. Using this little language, you specify the rules for the set of possible strings that you wan...
Introduction ============ Regular expressions (called REs, or regexes, or regex patterns) are essentially a tiny, highly specialized programming language embedded inside Python and made available through the :mod:`re` module. Using this little language, you specify the rules for the set of possible strings that you wan...
python, official-docs, cpython, P0
Local_Trusted_Corpus
99df9ba8-d343-40e2-be7f-c2f113e9895a
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,422
supabase-export-v2
4b9099389fa389a2
it has tried zero matches for ``[bcd]*``, and if that subsequently fails, the engine will conclude that the string doesn't match the RE at all. Another repeating metacharacter is ``+``, which matches one or more times. Pay careful attention to the difference between ``*`` and ``+``; ``*`` matches *zero* or more times, ...
trusted_official_docs
CPython Docs
it has tried zero matches for ``[bcd]*``, and if that subsequently fails, the engine will conclude that the string doesn't match the RE at all. Another repeating metacharacter is ``+``, which matches one or more times. Pay careful attention to the difference between ``*`` and ``+``; ``*`` matches *zero* or more times, ...
it has tried zero matches for ``[bcd]*``, and if that subsequently fails, the engine will conclude that the string doesn't match the RE at all. Another repeating metacharacter is ``+``, which matches one or more times. Pay careful attention to the difference between ``*`` and ``+``; ``*`` matches *zero* or more times, ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
9b2c38ef-562f-4cc7-a5c1-a9890bbd34ec
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,558
supabase-export-v2
88f9d59d6ae01f1f
>>> p = re.compile(r'(?P<word>\b\w+\b)') >>> m = p.search( '(((( Lots of punctuation )))' ) >>> m.group('word') 'Lots' >>> m.group(1) 'Lots' Additionally, you can retrieve named groups as a dictionary with :meth:`~re.Match.groupdict`::
trusted_official_docs
CPython Docs
>>> p = re.compile(r'(?P<word>\b\w+\b)') >>> m = p.search( '(((( Lots of punctuation )))' ) >>> m.group('word') 'Lots' >>> m.group(1) 'Lots' Additionally, you can retrieve named groups as a dictionary with :meth:`~re.Match.groupdict`::
>>> p = re.compile(r'(?P<word>\b\w+\b)') >>> m = p.search( '(((( Lots of punctuation )))' ) >>> m.group('word') 'Lots' >>> m.group(1) 'Lots' Additionally, you can retrieve named groups as a dictionary with :meth:`~re.Match.groupdict`::
python, official-docs, cpython, P0
Local_Trusted_Corpus
9e1adee6-fc92-4504-bcb3-3960445e6149
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,517
supabase-export-v2
52a138a8cc0c20e3
To match a literal ``'$'``, use ``\$`` or enclose it inside a character class, as in ``[$]``. ``\A`` Matches only at the start of the string. When not in :const:`MULTILINE` mode, ``\A`` and ``^`` are effectively the same. In :const:`MULTILINE` mode, they're different: ``\A`` still matches only at the beginning of th...
trusted_official_docs
CPython Docs
To match a literal ``'$'``, use ``\$`` or enclose it inside a character class, as in ``[$]``. ``\A`` Matches only at the start of the string. When not in :const:`MULTILINE` mode, ``\A`` and ``^`` are effectively the same. In :const:`MULTILINE` mode, they're different: ``\A`` still matches only at the beginning of th...
To match a literal ``'$'``, use ``\$`` or enclose it inside a character class, as in ``[$]``. ``\A`` Matches only at the start of the string. When not in :const:`MULTILINE` mode, ``\A`` and ``^`` are effectively the same. In :const:`MULTILINE` mode, they're different: ``\A`` still matches only at the beginning of th...
python, official-docs, cpython, P0
Local_Trusted_Corpus
9e9bca0a-6571-4575-8fee-1f9024cd6b4f
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,520
supabase-export-v2
60e8962668cb8a31
``\Z`` The same as ``\z``. For compatibility with old Python versions. ``\b`` Word boundary. This is a zero-width assertion that matches only at the beginning or end of a word. A word is defined as a sequence of alphanumeric characters, so the end of a word is indicated by whitespace or a non-alphanumeric character...
trusted_official_docs
CPython Docs
``\Z`` The same as ``\z``. For compatibility with old Python versions. ``\b`` Word boundary. This is a zero-width assertion that matches only at the beginning or end of a word. A word is defined as a sequence of alphanumeric characters, so the end of a word is indicated by whitespace or a non-alphanumeric character...
``\Z`` The same as ``\z``. For compatibility with old Python versions. ``\b`` Word boundary. This is a zero-width assertion that matches only at the beginning or end of a word. A word is defined as a sequence of alphanumeric characters, so the end of a word is indicated by whitespace or a non-alphanumeric character...
python, official-docs, cpython, P0
Local_Trusted_Corpus
9f307c23-0d98-410c-9960-e43a2bc20aee
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,426
supabase-export-v2
bf221560d2a63301
assumed for the missing value. Omitting *m* is interpreted as a lower limit of 0, while omitting *n* results in an upper bound of infinity. The simplest case ``{m}`` matches the preceding item exactly *m* times. For example, ``a/{2}b`` will only match ``'a//b'``.
trusted_official_docs
CPython Docs
assumed for the missing value. Omitting *m* is interpreted as a lower limit of 0, while omitting *n* results in an upper bound of infinity. The simplest case ``{m}`` matches the preceding item exactly *m* times. For example, ``a/{2}b`` will only match ``'a//b'``.
assumed for the missing value. Omitting *m* is interpreted as a lower limit of 0, while omitting *n* results in an upper bound of infinity. The simplest case ``{m}`` matches the preceding item exactly *m* times. For example, ``a/{2}b`` will only match ``'a//b'``.
python, official-docs, cpython, P0
Local_Trusted_Corpus
9fe4aadc-c62e-44d8-88f6-f97de74d8ecf
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,539
supabase-export-v2
fca8e97d04c81d84
can be passed multiple group numbers at a time, in which case it will return a tuple containing the corresponding values for those groups. :: >>> m.group(2,1,2) ('b', 'abc', 'b')
trusted_official_docs
CPython Docs
can be passed multiple group numbers at a time, in which case it will return a tuple containing the corresponding values for those groups. :: >>> m.group(2,1,2) ('b', 'abc', 'b')
can be passed multiple group numbers at a time, in which case it will return a tuple containing the corresponding values for those groups. :: >>> m.group(2,1,2) ('b', 'abc', 'b')
python, official-docs, cpython, P0
Local_Trusted_Corpus
a1967185-c725-4444-a3e4-121b9f1f9a73
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,612
supabase-export-v2
084420c1fc451675
This example matches the word ``section`` followed by a string enclosed in ``{``, ``}``, and changes ``section`` to ``subsection``:: >>> p = re.compile('section{ ( [^}]* ) }', re.VERBOSE) >>> p.sub(r'subsection{\1}','section{First} section{second}') 'subsection{First} subsection{second}'
trusted_official_docs
CPython Docs
This example matches the word ``section`` followed by a string enclosed in ``{``, ``}``, and changes ``section`` to ``subsection``:: >>> p = re.compile('section{ ( [^}]* ) }', re.VERBOSE) >>> p.sub(r'subsection{\1}','section{First} section{second}') 'subsection{First} subsection{second}'
This example matches the word ``section`` followed by a string enclosed in ``{``, ``}``, and changes ``section`` to ``subsection``:: >>> p = re.compile('section{ ( [^}]* ) }', re.VERBOSE) >>> p.sub(r'subsection{\1}','section{First} section{second}') 'subsection{First} subsection{second}'
python, official-docs, cpython, P0
Local_Trusted_Corpus
a25d3cd9-5ef6-4141-8524-b05afa5ddb54
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,642
supabase-export-v2
679a7ac1b09cb533
Using re.VERBOSE ---------------- By now you've probably noticed that regular expressions are a very compact notation, but they're not terribly readable. REs of moderate complexity can become lengthy collections of backslashes, parentheses, and metacharacters, making them difficult to read and understand.
trusted_official_docs
CPython Docs
Using re.VERBOSE ---------------- By now you've probably noticed that regular expressions are a very compact notation, but they're not terribly readable. REs of moderate complexity can become lengthy collections of backslashes, parentheses, and metacharacters, making them difficult to read and understand.
Using re.VERBOSE ---------------- By now you've probably noticed that regular expressions are a very compact notation, but they're not terribly readable. REs of moderate complexity can become lengthy collections of backslashes, parentheses, and metacharacters, making them difficult to read and understand.
python, official-docs, cpython, P0
Local_Trusted_Corpus
a2621858-e176-4bf7-8d30-c257156ef492
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,443
supabase-export-v2
2ca99fcd9ad797e5
regular Python string literal. In REs that feature backslashes repeatedly, this leads to lots of repeated backslashes and makes the resulting strings difficult to understand. The solution is to use Python's raw string notation for regular expressions; backslashes are not handled in any special way in a string literal p...
trusted_official_docs
CPython Docs
regular Python string literal. In REs that feature backslashes repeatedly, this leads to lots of repeated backslashes and makes the resulting strings difficult to understand. The solution is to use Python's raw string notation for regular expressions; backslashes are not handled in any special way in a string literal p...
regular Python string literal. In REs that feature backslashes repeatedly, this leads to lots of repeated backslashes and makes the resulting strings difficult to understand. The solution is to use Python's raw string notation for regular expressions; backslashes are not handled in any special way in a string literal p...
python, official-docs, cpython, P0
Local_Trusted_Corpus
a445c5b8-b797-4165-9f85-a8c1bdac8511
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,455
supabase-export-v2
875fbe1d2ecd983a
in this case, which will cause the interpreter to print no output. You can explicitly print the result of :meth:`!search` to make this clear. :: >>> p.search("") >>> print(p.search("")) None
trusted_official_docs
CPython Docs
in this case, which will cause the interpreter to print no output. You can explicitly print the result of :meth:`!search` to make this clear. :: >>> p.search("") >>> print(p.search("")) None
in this case, which will cause the interpreter to print no output. You can explicitly print the result of :meth:`!search` to make this clear. :: >>> p.search("") >>> print(p.search("")) None
python, official-docs, cpython, P0
Local_Trusted_Corpus
a4d3ceed-f197-4745-a442-d4cf3aee9ad1
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,429
supabase-export-v2
34ed5fc01105baa4
Using regular expressions ========================= Now that we've looked at some simple regular expressions, how do we actually use them in Python? The :mod:`re` module provides an interface to the regular expression engine, allowing you to compile REs into objects and then perform matches with them.
trusted_official_docs
CPython Docs
Using regular expressions ========================= Now that we've looked at some simple regular expressions, how do we actually use them in Python? The :mod:`re` module provides an interface to the regular expression engine, allowing you to compile REs into objects and then perform matches with them.
Using regular expressions ========================= Now that we've looked at some simple regular expressions, how do we actually use them in Python? The :mod:`re` module provides an interface to the regular expression engine, allowing you to compile REs into objects and then perform matches with them.
python, official-docs, cpython, P0
Local_Trusted_Corpus
a5846ee1-1bca-437f-9ca3-3c1d4a53c082
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,587
supabase-export-v2
47729f97f772ea6a
Modifying strings ================= Up to this point, we've simply performed searches against a static string. Regular expressions are also commonly used to modify strings in various ways, using the following pattern methods:
trusted_official_docs
CPython Docs
Modifying strings ================= Up to this point, we've simply performed searches against a static string. Regular expressions are also commonly used to modify strings in various ways, using the following pattern methods:
Modifying strings ================= Up to this point, we've simply performed searches against a static string. Regular expressions are also commonly used to modify strings in various ways, using the following pattern methods:
python, official-docs, cpython, P0
Local_Trusted_Corpus
a695b460-84e1-460e-a02b-140dce721ace
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,596
supabase-export-v2
36f19bc5c01a075b
delimiter was. If capturing parentheses are used in the RE, then their values are also returned as part of the list. Compare the following calls:: >>> p = re.compile(r'\W+') >>> p2 = re.compile(r'(\W+)') >>> p.split('This... is a test.') ['This', 'is', 'a', 'test', ''] >>> p2.split('This... is a test.') ['This', '...
trusted_official_docs
CPython Docs
delimiter was. If capturing parentheses are used in the RE, then their values are also returned as part of the list. Compare the following calls:: >>> p = re.compile(r'\W+') >>> p2 = re.compile(r'(\W+)') >>> p.split('This... is a test.') ['This', 'is', 'a', 'test', ''] >>> p2.split('This... is a test.') ['This', '...
delimiter was. If capturing parentheses are used in the RE, then their values are also returned as part of the list. Compare the following calls:: >>> p = re.compile(r'\W+') >>> p2 = re.compile(r'(\W+)') >>> p.split('This... is a test.') ['This', 'is', 'a', 'test', ''] >>> p2.split('This... is a test.') ['This', '...
python, official-docs, cpython, P0
Local_Trusted_Corpus
a6e7a32b-dc32-44b4-9f93-457e62ed924a
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,448
supabase-export-v2
c078da622da32b49
it? Pattern objects have several methods and attributes. Only the most significant ones will be covered here; consult the :mod:`re` docs for a complete listing. +------------------+-----------------------------------------------+ | Method/Attribute | Purpose | +==================+=======================================...
trusted_official_docs
CPython Docs
it? Pattern objects have several methods and attributes. Only the most significant ones will be covered here; consult the :mod:`re` docs for a complete listing. +------------------+-----------------------------------------------+ | Method/Attribute | Purpose | +==================+=======================================...
it? Pattern objects have several methods and attributes. Only the most significant ones will be covered here; consult the :mod:`re` docs for a complete listing. +------------------+-----------------------------------------------+ | Method/Attribute | Purpose | +==================+=======================================...
python, official-docs, cpython, P0
Local_Trusted_Corpus
a76b8491-3aaf-4994-8c7b-571a756ab4b9
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,490
supabase-export-v2
df0841d9683eaebe
(``^`` and ``$`` haven't been explained yet; they'll be introduced in section :ref:`more-metacharacters`.) Usually ``^`` matches only at the beginning of the string, and ``$`` matches only at the end of the string and immediately before the newline (if any) at the end of the string. When this flag is specified, ``^``...
trusted_official_docs
CPython Docs
(``^`` and ``$`` haven't been explained yet; they'll be introduced in section :ref:`more-metacharacters`.) Usually ``^`` matches only at the beginning of the string, and ``$`` matches only at the end of the string and immediately before the newline (if any) at the end of the string. When this flag is specified, ``^``...
(``^`` and ``$`` haven't been explained yet; they'll be introduced in section :ref:`more-metacharacters`.) Usually ``^`` matches only at the beginning of the string, and ``$`` matches only at the end of the string and immediately before the newline (if any) at the end of the string. When this flag is specified, ``^``...
python, official-docs, cpython, P0
Local_Trusted_Corpus
a7aec044-8d90-40fc-8d86-927143247c14
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,521
supabase-export-v2
10725f45e7d0f3b8
word. A word is defined as a sequence of alphanumeric characters, so the end of a word is indicated by whitespace or a non-alphanumeric character. The following example matches ``class`` only when it's a complete word; it won't match when it's contained inside another word. ::
trusted_official_docs
CPython Docs
word. A word is defined as a sequence of alphanumeric characters, so the end of a word is indicated by whitespace or a non-alphanumeric character. The following example matches ``class`` only when it's a complete word; it won't match when it's contained inside another word. ::
word. A word is defined as a sequence of alphanumeric characters, so the end of a word is indicated by whitespace or a non-alphanumeric character. The following example matches ``class`` only when it's a complete word; it won't match when it's contained inside another word. ::
python, official-docs, cpython, P0
Local_Trusted_Corpus
a871f251-f5aa-4df9-9816-a18d67a29a20
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,593
supabase-export-v2
681ce03a612a3c3b
the RE, then their contents will also be returned as part of the resulting list. If *maxsplit* is nonzero, at most *maxsplit* splits are performed. You can limit the number of splits made, by passing a value for *maxsplit*. When *maxsplit* is nonzero, at most *maxsplit* splits will be made, and the remainder of the str...
trusted_official_docs
CPython Docs
the RE, then their contents will also be returned as part of the resulting list. If *maxsplit* is nonzero, at most *maxsplit* splits are performed. You can limit the number of splits made, by passing a value for *maxsplit*. When *maxsplit* is nonzero, at most *maxsplit* splits will be made, and the remainder of the str...
the RE, then their contents will also be returned as part of the resulting list. If *maxsplit* is nonzero, at most *maxsplit* splits are performed. You can limit the number of splits made, by passing a value for *maxsplit*. When *maxsplit* is nonzero, at most *maxsplit* splits will be made, and the remainder of the str...
python, official-docs, cpython, P0
Local_Trusted_Corpus
a8e030d3-ea75-423a-a73f-ebc16b66a56f
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,556
supabase-export-v2
1cc07fef386840f7
A more significant feature is named groups: instead of referring to them by numbers, groups can be referenced by a name. The syntax for a named group is one of the Python-specific extensions: ``(?P<name>...)``. *name* is, obviously, the name of the group. Named groups behave exactly like capturing groups, and additiona...
trusted_official_docs
CPython Docs
A more significant feature is named groups: instead of referring to them by numbers, groups can be referenced by a name. The syntax for a named group is one of the Python-specific extensions: ``(?P<name>...)``. *name* is, obviously, the name of the group. Named groups behave exactly like capturing groups, and additiona...
A more significant feature is named groups: instead of referring to them by numbers, groups can be referenced by a name. The syntax for a named group is one of the Python-specific extensions: ``(?P<name>...)``. *name* is, obviously, the name of the group. Named groups behave exactly like capturing groups, and additiona...
python, official-docs, cpython, P0
Local_Trusted_Corpus
a8f81730-165b-4cd6-bd51-729c00ef639e
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,466
supabase-export-v2
82261876dd371526
p = re.compile( ... ) m = p.search( 'string goes here' ) if m: print('Match found: ', m.group()) else: print('No match') Two pattern methods return all of the matches for a pattern. :meth:`~re.Pattern.findall` returns a list of matching strings::
trusted_official_docs
CPython Docs
p = re.compile( ... ) m = p.search( 'string goes here' ) if m: print('Match found: ', m.group()) else: print('No match') Two pattern methods return all of the matches for a pattern. :meth:`~re.Pattern.findall` returns a list of matching strings::
p = re.compile( ... ) m = p.search( 'string goes here' ) if m: print('Match found: ', m.group()) else: print('No match') Two pattern methods return all of the matches for a pattern. :meth:`~re.Pattern.findall` returns a list of matching strings::
python, official-docs, cpython, P0
Local_Trusted_Corpus
a9a0b43c-b7b8-44b5-b6ee-0ced791d7d4d
CPython Docs
file://datasets/cpython/Doc/howto/regex.rst
unknown
a0410288-0e34-49d0-91b0-b1fbbd428672
57,508
supabase-export-v2
6f309041cb114824
zero-width assertions should never be repeated, because if they match once at a given location, they can obviously be matched an infinite number of times. ``|`` Alternation, or the "or" operator. If *A* and *B* are regular expressions, ``A|B`` will match any string that matches either *A* or *B*. ``|`` has very low ...
trusted_official_docs
CPython Docs
zero-width assertions should never be repeated, because if they match once at a given location, they can obviously be matched an infinite number of times. ``|`` Alternation, or the "or" operator. If *A* and *B* are regular expressions, ``A|B`` will match any string that matches either *A* or *B*. ``|`` has very low ...
zero-width assertions should never be repeated, because if they match once at a given location, they can obviously be matched an infinite number of times. ``|`` Alternation, or the "or" operator. If *A* and *B* are regular expressions, ``A|B`` will match any string that matches either *A* or *B*. ``|`` has very low ...
python, official-docs, cpython, P0
Local_Trusted_Corpus