Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
daa1fa99
Kaydet (Commit)
daa1fa99
authored
Eki 13, 2013
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Back out accidentally pushed changeset b51218966201.
üst
a7bb9b3a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
70 deletions
+11
-70
re.rst
Doc/library/re.rst
+0
-28
re.py
Lib/re.py
+11
-17
test_re.py
Lib/test/test_re.py
+0
-24
_sre.c
Modules/_sre.c
+0
-0
sre.h
Modules/sre.h
+0
-1
No files found.
Doc/library/re.rst
Dosyayı görüntüle @
daa1fa99
...
...
@@ -584,16 +584,6 @@ form.
instead (see also :ref:`search-vs-match`).
.. function:: fullmatch(pattern, string, flags=0)
If the whole *string* matches the regular expression *pattern*, return a
corresponding :ref:`match object <match-objects>`. Return ``None`` if the
string does not match the pattern; note that this is different from a
zero-length match.
.. versionadded:: 3.4
.. function:: split(pattern, string, maxsplit=0, flags=0)
Split *string* by the occurrences of *pattern*. If capturing parentheses are
...
...
@@ -788,24 +778,6 @@ attributes:
:meth:`~regex.search` instead (see also :ref:`search-vs-match`).
.. method:: regex.fullmatch(string[, pos[, endpos]])
If the whole *string* matches this regular expression, return a corresponding
:ref:`match object <match-objects>`. Return ``None`` if the string does not
match the pattern; note that this is different from a zero-length match.
The optional *pos* and *endpos* parameters have the same meaning as for the
:meth:`~regex.search` method.
>>> pattern = re.compile("o[gh]")
>>> pattern.fullmatch("dog") # No match as "o" is not at the start of "dog".
>>> pattern.fullmatch("ogre") # No match as not the full string matches.
>>> pattern.fullmatch("doggie", 1, 3) # Matches within given limits.
<_sre.SRE_Match object at ...>
.. versionadded:: 3.4
.. method:: regex.split(string, maxsplit=0)
Identical to the :func:`split` function, using the compiled pattern.
...
...
Lib/re.py
Dosyayı görüntüle @
daa1fa99
...
...
@@ -85,17 +85,16 @@ resulting RE will match the second character.
\\ Matches a literal backslash.
This module exports the following functions:
match Match a regular expression pattern to the beginning of a string.
fullmatch Match a regular expression pattern to all of a string.
search Search a string for the presence of a pattern.
sub Substitute occurrences of a pattern found in a string.
subn Same as sub, but also return the number of substitutions made.
split Split a string by the occurrences of a pattern.
findall Find all occurrences of a pattern in a string.
finditer Return an iterator yielding a match object for each match.
compile Compile a pattern into a RegexObject.
purge Clear the regular expression cache.
escape Backslash all non-alphanumerics in a string.
match Match a regular expression pattern to the beginning of a string.
search Search a string for the presence of a pattern.
sub Substitute occurrences of a pattern found in a string.
subn Same as sub, but also return the number of substitutions made.
split Split a string by the occurrences of a pattern.
findall Find all occurrences of a pattern in a string.
finditer Return an iterator yielding a match object for each match.
compile Compile a pattern into a RegexObject.
purge Clear the regular expression cache.
escape Backslash all non-alphanumerics in a string.
Some of the functions in this module takes flags as optional parameters:
A ASCII For string patterns, make \w, \W, \b, \B, \d, \D
...
...
@@ -124,7 +123,7 @@ import sre_compile
import
sre_parse
# public symbols
__all__
=
[
"match"
,
"
fullmatch"
,
"
search"
,
"sub"
,
"subn"
,
"split"
,
"findall"
,
__all__
=
[
"match"
,
"search"
,
"sub"
,
"subn"
,
"split"
,
"findall"
,
"compile"
,
"purge"
,
"template"
,
"escape"
,
"A"
,
"I"
,
"L"
,
"M"
,
"S"
,
"X"
,
"U"
,
"ASCII"
,
"IGNORECASE"
,
"LOCALE"
,
"MULTILINE"
,
"DOTALL"
,
"VERBOSE"
,
"UNICODE"
,
"error"
]
...
...
@@ -155,11 +154,6 @@ def match(pattern, string, flags=0):
a match object, or None if no match was found."""
return
_compile
(
pattern
,
flags
)
.
match
(
string
)
def
fullmatch
(
pattern
,
string
,
flags
=
0
):
"""Try to apply the pattern to all of the string, returning
a match object, or None if no match was found."""
return
_compile
(
pattern
,
flags
)
.
fullmatch
(
string
)
def
search
(
pattern
,
string
,
flags
=
0
):
"""Scan through string looking for a match to the pattern, returning
a match object, or None if no match was found."""
...
...
Lib/test/test_re.py
Dosyayı görüntüle @
daa1fa99
...
...
@@ -1061,30 +1061,6 @@ class ReTests(unittest.TestCase):
self
.
assertEqual
(
m
.
group
(
1
),
""
)
self
.
assertEqual
(
m
.
group
(
2
),
"y"
)
def
test_fullmatch
(
self
):
# Issue 16203: Proposal: add re.fullmatch() method.
self
.
assertEqual
(
re
.
fullmatch
(
r"a"
,
"a"
)
.
span
(),
(
0
,
1
))
self
.
assertEqual
(
re
.
fullmatch
(
r"a|ab"
,
"ab"
)
.
span
(),
(
0
,
2
))
self
.
assertEqual
(
re
.
fullmatch
(
r".*?$"
,
"abc"
)
.
span
(),
(
0
,
3
))
self
.
assertEqual
(
re
.
fullmatch
(
r".*?"
,
"abc"
)
.
span
(),
(
0
,
3
))
self
.
assertEqual
(
re
.
fullmatch
(
r"a.*?b"
,
"ab"
)
.
span
(),
(
0
,
2
))
self
.
assertEqual
(
re
.
fullmatch
(
r"a.*?b"
,
"abb"
)
.
span
(),
(
0
,
3
))
self
.
assertEqual
(
re
.
fullmatch
(
r"a.*?b"
,
"axxb"
)
.
span
(),
(
0
,
4
))
self
.
assertEqual
(
re
.
fullmatch
(
r"abc$"
,
"abc
\n
"
),
None
)
self
.
assertEqual
(
re
.
fullmatch
(
r"abc\Z"
,
"abc
\n
"
),
None
)
self
.
assertEqual
(
re
.
fullmatch
(
r"(?m)abc$"
,
"abc
\n
"
),
None
)
self
.
assertEqual
(
re
.
fullmatch
(
r"ab(?=c)cd"
,
"abcd"
)
.
span
(),
(
0
,
4
))
self
.
assertEqual
(
re
.
fullmatch
(
r"ab(?<=b)cd"
,
"abcd"
)
.
span
(),
(
0
,
4
))
self
.
assertEqual
(
re
.
fullmatch
(
r"(?=a|ab)ab"
,
"ab"
)
.
span
(),
(
0
,
2
))
self
.
assertEqual
(
re
.
compile
(
r"bc"
)
.
fullmatch
(
"abcd"
,
pos
=
1
,
endpos
=
3
)
.
span
(),
(
1
,
3
))
self
.
assertEqual
(
re
.
compile
(
r".*?$"
)
.
fullmatch
(
"abcd"
,
pos
=
1
,
endpos
=
3
)
.
span
(),
(
1
,
3
))
self
.
assertEqual
(
re
.
compile
(
r".*?"
)
.
fullmatch
(
"abcd"
,
pos
=
1
,
endpos
=
3
)
.
span
(),
(
1
,
3
))
def
run_re_tests
():
from
test.re_tests
import
tests
,
SUCCEED
,
FAIL
,
SYNTAX_ERROR
if
verbose
:
...
...
Modules/_sre.c
Dosyayı görüntüle @
daa1fa99
This diff is collapsed.
Click to expand it.
Modules/sre.h
Dosyayı görüntüle @
daa1fa99
...
...
@@ -89,7 +89,6 @@ typedef struct {
SRE_REPEAT
*
repeat
;
/* hooks */
SRE_TOLOWER_HOOK
lower
;
int
match_all
;
}
SRE_STATE
;
typedef
struct
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment