Moved comments inline in mix page

This commit is contained in:
=
2012-09-19 21:39:16 +01:00
parent b6bc118ba2
commit fbe14f7fa9
540 changed files with 112 additions and 79 deletions

14
core/utils/string.py Normal file
View File

@@ -0,0 +1,14 @@
__author__ = 'fergalm'
import re
def lreplace(string, pattern, sub):
"""
Replaces 'pattern' in 'string' with 'sub' if 'pattern' starts 'string'.
"""
return re.sub('^%s' % pattern, sub, string)
def rreplace(string, pattern, sub):
"""
Replaces 'pattern' in 'string' with 'sub' if 'pattern' ends 'string'.
"""
return re.sub('%s$' % pattern, sub, string)