Add regular expression escaping filter.
This commit is contained in:
parent
0b6fadaad7
commit
c1e4085251
1 changed files with 5 additions and 0 deletions
|
@ -222,6 +222,10 @@ def version_compare(value, version, operator='eq', strict=False):
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
raise errors.AnsibleFilterError('Version comparison: %s' % e)
|
raise errors.AnsibleFilterError('Version comparison: %s' % e)
|
||||||
|
|
||||||
|
def re_escape(string):
|
||||||
|
'''Escape all regular expressions special characters from STRING.'''
|
||||||
|
return re.escape(string)
|
||||||
|
|
||||||
@environmentfilter
|
@environmentfilter
|
||||||
def rand(environment, end, start=None, step=None):
|
def rand(environment, end, start=None, step=None):
|
||||||
r = SystemRandom()
|
r = SystemRandom()
|
||||||
|
@ -356,6 +360,7 @@ class FilterModule(object):
|
||||||
'search': search,
|
'search': search,
|
||||||
'regex': regex,
|
'regex': regex,
|
||||||
'regex_replace': regex_replace,
|
'regex_replace': regex_replace,
|
||||||
|
're_escape': re_escape,
|
||||||
|
|
||||||
# ? : ;
|
# ? : ;
|
||||||
'ternary': ternary,
|
'ternary': ternary,
|
||||||
|
|
Loading…
Reference in a new issue