[telepathy-doc/master] Fix regular expressions

Davyd Madeley davyd at madeley.id.au
Thu Apr 2 00:56:27 PDT 2009


---
 docs/book/insert-examples.py |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/docs/book/insert-examples.py b/docs/book/insert-examples.py
index fc07973..2f633c4 100755
--- a/docs/book/insert-examples.py
+++ b/docs/book/insert-examples.py
@@ -64,8 +64,8 @@ for example in examples:
 	if id:
 		print >> sys.stderr, "Including `%s' from `%s'..." % (id, filename)
 
-		begin_re = re.compile ('begin %s(\\s|$)' % id)
-		end_re = re.compile ('end %s(\\s|$)' % id)
+		begin_re = re.compile ('begin %s(\\s|$)' % re.escape (id), re.I)
+		end_re = re.compile ('end %s(\\s|$)' % re.escape (id), re.I)
 
 		begin = False
 		lines = []
@@ -145,10 +145,10 @@ for nicename in included_files:
 	
 
 	for id in included_files[nicename]:
-		sre = re.compile ('(\\s)begin (%s)(\\s|$)' % re.escape (id), re.IGNORECASE)
+		sre = re.compile ('(\\W)begin (%s)(\\W)' % re.escape (id), re.I | re.M)
 		contents = sre.sub(r'\1Begin <embeddb><xref linkend="\2"/></embeddb>\3', contents)
 
-		sre = re.compile ('(\\s)end (%s)(\\s|$)' % re.escape (id), re.IGNORECASE)
+		sre = re.compile ('(\\W)end (%s)(\\W)' % re.escape (id), re.I | re.M)
 		contents = sre.sub(r'\1End <embeddb><xref linkend="\2"/></embeddb>\3', contents)
 
 	pl = etree.SubElement (s, 'programlisting')
-- 
1.5.6.5




More information about the telepathy-commits mailing list