mirror of
https://github.com/fergalmoran/dss.git
synced 2025-12-25 19:17:35 +00:00
Moved comments inline in mix page
This commit is contained in:
14
core/utils/string.py
Normal file
14
core/utils/string.py
Normal 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)
|
||||
Reference in New Issue
Block a user