core.render.html.env.regex

Module Contents

Functions

regexMatch(render, pattern, string, flags=0)

Jinja2 global: Match a string for regular expression pattern.

regexReplace(render, s, pattern, replace)

Jinja2 global: Replace string by regular expression pattern.

regexSearch(render, s, pattern, flags=0)

Jinja2 global: Search a string for regular expression pattern.

core.render.html.env.regex.regexMatch(render, pattern, string, flags=0)

Jinja2 global: Match a string for regular expression pattern. This function internally runs re.match().

Parameters
  • s (str) – String where to be searched in.

  • pattern (str) – Regular expression pattern to be matched.

  • flags (int) – Flags to be passed to re.search().

Returns

A matching object on success, else None.

Return type

re.MatchObject

core.render.html.env.regex.regexReplace(render, s, pattern, replace)

Jinja2 global: Replace string by regular expression pattern.

Parameters
  • s (str) – String to be replaced.

  • pattern (str) – Regular expression pattern to be matched.

  • replace (str) – Replacement string to be inserted for every matching pattern.

Returns

The string with the replaced matches.

Return type

str

core.render.html.env.regex.regexSearch(render, s, pattern, flags=0)

Jinja2 global: Search a string for regular expression pattern. This function internally runs re.search().

Parameters
  • s (str) – String where to be searched in.

  • pattern (str) – Regular expression pattern to be matched.

  • flags (int) – Flags to be passed to re.search().

Returns

A matching object on success, else None.

Return type

re.MatchObject