Commits

Olemis Lang  committed 949f294

Brython #26 : MatchObject.expand [work in progress]

  • Participants
  • Parent commits 5411ca3
  • Branches t26_module_re

Comments (0)

Files changed (2)

+t26/t26_r0218b8f_matchobject_expand.diff
 # Placed by Bitbucket

File t26/t26_r0218b8f_matchobject_expand.diff

+# HG changeset patch
+# Parent a14a01be9ab96554d220d393fffc68d85c15672d
+Brython: refs #26 MatchObject.expand
+
+diff -r a14a01be9ab9 src/Lib/re.py
+--- a/src/Lib/re.py	Sun Apr 07 12:20:17 2013 -0500
++++ b/src/Lib/re.py	Sun Apr 07 22:40:41 2013 -0500
+@@ -1,5 +1,7 @@
+ I = 'i'
+ 
++_RE_PY2JS = __BRYTHON__.re('[\](\d+)', 'g')
++
+ class MatchObject:
+ 
+     def __init__(self,jsmatch):
+@@ -21,6 +23,10 @@
+             return tuple(x if x is not None else default_ 
+                          for x in self._jsmatch[1:])
+ 
++    def expand(template):
++        _template = template.replace(_RE_PY2JS, '$$$1')
++        return _template
++
+ def search(pattern,src,flags=None):
+     # FIXME : Check whether `g` is appropriate as this is used for match too
+     flag = 'g'