Commit Graph

50 Commits

Author SHA1 Message Date
Žiga Seilnacht
7492e4260e Bug #1675967: re patterns pickled with older Python versions can
now be unpickled. Will backport.
2007-03-21 20:07:56 +00:00
Neal Norwitz
f0e2c07a74 Spel compatibility write. 2006-03-16 06:33:21 +00:00
Neal Norwitz
f521de6efc Add back an sre.py that should be backwards compatible except for the warning. 2006-03-16 06:31:02 +00:00
Neal Norwitz
94a9c09e10 Rename sre.py -> re.py 2006-03-16 06:30:02 +00:00
Raymond Hettinger
ebb7f30111 Speed-up escape() 2005-09-12 22:50:37 +00:00
Raymond Hettinger
596ba4d89e Granted Noam Raphael's request for minor improvements to the re module and
its documentation.

* Documented that the compiled re methods are supposed to be more full
  featured than their simpilified function counterparts.

* Documented the existing start and stop position arguments for the
  findall() and finditer() methods of compiled regular expression objects.

* Added an optional flags argument to the re.findall() and re.finditer()
  functions.  This aligns their API with that for re.search() and
  re.match().
2004-09-24 03:41:05 +00:00
Barry Warsaw
8bee76106e PEP 292 classes Template and SafeTemplate are added to the string module.
This patch includes test cases and documentation updates, as well as NEWS file
updates.

This patch also updates the sre modules so that they don't import the string
module, breaking direct circular imports.
2004-08-25 02:22:30 +00:00
Andrew M. Kuchling
43ab0cd174 [Bug #990792] Mention that repl can be a callable 2004-08-07 17:41:54 +00:00
Hye-Shik Chang
0f5bf1ebdd SF #926075: Fixed the bug that returns a wrong pattern object for
a string or unicode object in sre.compile() when a different type
pattern with the same value exists.
2004-04-20 21:11:11 +00:00
Just van Rossum
74902508dc Addendum to #764548: restore 2.1 compatibility. 2003-07-02 21:37:16 +00:00
Just van Rossum
12723bacea Fix and test for bug #764548:
Use isinstance() instead of comparing types directly, to enable
subclasses of str and unicode to be used as patterns.
Blessed by /F.
2003-07-02 20:03:04 +00:00
Guido van Rossum
0d976551fb Add finditer to __all__ (when defining it at all).
SF bug 585882.  Will forward-port.
2002-10-14 12:22:17 +00:00
Fredrik Lundh
b7747e2a2d added finditer sanity check 2001-10-28 20:15:40 +00:00
Fredrik Lundh
703ce8122c (experimental) "finditer" method/function. this works pretty much
like findall, but returns an iterator (which returns match objects)
instead of a list of strings/tuples.
2001-10-24 22:16:30 +00:00
Fredrik Lundh
dac58492aa fixed character set description in docstring (SRE uses Python
strings, not C strings)

removed USE_PYTHON defines, and related sre.py helpers

skip calling the subx helper if the template is callable.
interestingly enough, this means that

	def callback(m):
	    return literal
	result = pattern.sub(callback, string)

is much faster than

	result = pattern.sub(literal, string)
2001-10-21 21:48:30 +00:00
Fredrik Lundh
1296a8d77e sre.Scanner fixes (from Greg Chapman). also added a Scanner sanity
check to the test suite.

added a few missing exception checks in the _sre module
2001-10-21 18:04:11 +00:00
Fredrik Lundh
bec95b9d88 rewrote the pattern.sub and pattern.subn methods in C
removed (conceptually flawed) getliteral helper; the new sub/subn code
uses a faster code path for literal replacement strings, but doesn't
(yet) look for literal patterns.

added STATE_OFFSET macro, and use it to convert state.start/ptr to
char indexes
2001-10-21 16:47:57 +00:00
Fredrik Lundh
397a654791 SRE bug #441409:
compile should raise error for non-strings
SRE bug #432570, 448951:
    reset group after failed match

also bumped version number to 2.2.0
2001-10-18 19:30:16 +00:00
Fredrik Lundh
59b68656f8 fixed #449964: sre.sub raises an exception if the template contains a
\g<x> group reference followed by a character escape

(also restructured a few things on the way to fixing #449000)
2001-09-18 20:55:24 +00:00
Fredrik Lundh
21009b9c6f an SRE bugfix a day keeps Guido away...
#462270: sub-tle difference between pre.sub and sre.sub.  PRE ignored
an empty match at the previous location, SRE didn't.

also synced with Secret Labs "sreopen" codebase.
2001-09-18 18:47:09 +00:00
Fred Drake
9f5b822fb3 Convert docstring to "raw" string. 2001-09-04 19:20:06 +00:00
Fred Drake
b8f2274985 Added docstrings by Neal Norwitz. This closes SF bug #450980. 2001-09-04 19:10:20 +00:00
Guido van Rossum
315cd29ecf Disable the sub() optimization until Fredrik has time to look into SF
bug #449000, "re.sub(r'\n', ...) broke".  This was Fredrik's
suggestion -- he's on vacation and said he wouldn't be able to work on
this until next week.
2001-08-10 14:56:54 +00:00
Fredrik Lundh
2d96f11d07 map re.sub() to string.replace(), when possible 2001-07-08 13:26:57 +00:00
Fredrik Lundh
e06cbb8c56 bug #436596
re.findall doesn't take a maxsplit argument
2001-07-06 20:56:10 +00:00