• Home
  • Raw
  • Download

Lines Matching refs:RE

11    Better way of displaying a RE, a string, and what it matches
37 necessary to pay careful attention to how the engine will execute a given RE,
38 and write the RE in a certain way in order to produce bytecode that runs faster.
67 enable a case-insensitive mode that would let this RE match ``Test`` or ``TEST``
73 of the RE by repeating them or changing their meaning. Much of this document is
89 characters. If you wanted to match only lowercase letters, your RE would be
169 portions of the RE must be repeated a certain number of times.
178 Repetitions such as ``*`` are :dfn:`greedy`; when repeating a RE, the matching
186 this RE against the string ``'abcbd'``.
191 | 1 | ``a`` | The ``a`` in the RE matches. |
219 The end of the RE has now been reached, and it has matched ``'abcb'``. This
221 match is found it will then progressively back up and retry the rest of the RE
224 string doesn't match the RE at all.
282 The RE is passed to :func:`re.compile` as a string. REs are handled as strings
303 Let's say you want to write a RE that matches the string ``\section``, which
321 In short, to match a literal backslash, one has to write ``'\\\\'`` as the RE
362 | ``match()`` | Determine if the RE matches at the beginning |
366 | | location where this RE matches. |
368 | ``findall()`` | Find all substrings where the RE matches, and |
371 | ``finditer()`` | Find all substrings where the RE matches, and |
384 whether the RE matches or fails. :file:`redemo.py` can be quite useful when
385 trying to debug a complicated RE.
388 Python interpreter, import the :mod:`re` module, and compile a RE::
395 Now, you can try matching various strings against the RE ``[a-z]+``. An empty
420 | ``group()`` | Return the string matched by the RE |
439 :meth:`~re.Match.group` returns the substring that was matched by the RE. :meth:`~re.Match.start`
442 method only checks if the RE matches at the start of a string, :meth:`!start`
502 the RE string added as the first argument, and still return either ``None`` or a
512 object in a cache, so future calls using the same RE won't need to
640 been specified, whitespace within the RE string is ignored, except when the
642 lets you organize and indent the RE more clearly. This flag also lets you put
643 comments within a RE that will be ignored by the engine; comments are marked by
647 For example, here's a RE that uses :const:`re.VERBOSE`; see how much easier it
660 Without the verbose setting, the RE would look like this::
667 been used to break up the RE into smaller pieces, but it's still more difficult
711 line, the RE to use is ``^From``. ::
764 convert the ``\b`` to a backspace, and your RE won't match as you expect it to.
765 The following example looks the same as our previous RE, but omits the ``'r'``
766 in front of the RE string. ::
786 Frequently you need to obtain more information than just whether the RE matched
787 or not. Regular expressions are often used to dissect strings by writing a RE
818 numbered starting with 0. Group 0 is always present; it's the whole RE, so
861 backreferences in a RE.
863 For example, the following RE detects doubled words in a string. ::
878 to group and structure the RE itself. In complex REs, it becomes difficult to
953 of having to remember numbers. Here's an example RE from the :mod:`imaplib`
1067 | | wherever the RE matches |
1069 | ``sub()`` | Find all substrings where the RE matches, and |
1082 wherever the RE matches, returning a list of the pieces. It's similar to the
1093 parentheses are used in the RE, then their contents will also be returned as
1111 the RE, then their values are also returned as part of the list. Compare the
1121 The module-level function :func:`re.split` adds the RE to be used as the first
1143 occurrences of the RE in *string* by the replacement *replacement*. If the
1179 corresponding group in the RE. This lets you incorporate portions of the
1254 into ``sdeedfish``, but the naive RE ``word`` would have done that, too. (To
1272 The :func:`~re.match` function only checks if the RE matches at the beginning of the
1292 to the front of your RE. Resist this temptation and use :func:`re.search`
1301 string and then backtracking to find a match for the rest of the RE. Use
1322 The RE matches the ``'<'`` in ``'<html>'``, and the ``.*`` consumes the rest of
1323 the string. There's still more left in the RE, though, and the ``>`` can't
1361 addition, you can also put comments inside a RE; comments extend from a ``#``