]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
fix example re such that the listen modifier example works
authorBrian <bmc@shmoo.com>
Sat, 17 Dec 2016 17:09:13 +0000 (12:09 -0500)
committerBrian <bmc@shmoo.com>
Sat, 17 Dec 2016 17:09:13 +0000 (12:09 -0500)
doc/build/core/event.rst
lib/sqlalchemy/orm/events.py

index 1a81dbac10de5f947772f95d7f946d6ab821b4e7..edc16e60351273024f22525f479f3030160d0e29 100644 (file)
@@ -129,7 +129,7 @@ this value can be supported::
     def validate_phone(target, value, oldvalue, initiator):
         """Strip non-numeric characters from a phone number"""
 
-        return re.sub(r'(?![0-9])', '', value)
+        return re.sub(r'\D', '', value)
 
     # setup listener on UserContact.phone attribute, instructing
     # it to use the return value
index 992f296235e3f665154dfa45f3ab9a3dcf801d91..6bb773536e70541c391b5a2723845599eb9cb485 100644 (file)
@@ -1812,7 +1812,7 @@ class AttributeEvents(event.Events):
         def validate_phone(target, value, oldvalue, initiator):
             "Strip non-numeric characters from a phone number"
 
-            return re.sub(r'(?![0-9])', '', value)
+            return re.sub(r'\D', '', value)
 
         # setup listener on UserContact.phone attribute, instructing
         # it to use the return value