ansible/ansible — pull request #4981 by tartansandal (2013-11-20 23:27:04+00:00)
Title: Add a 'capture' jinja2 filter

This filter returns the string captured by an arbitrary regex capture group.

For example, if

{{ foo_string }}

gives us

abc1234def

then

{{ foo_string | capture('abc(\d+)def') }}

gives us

1234

and

{{ foo_string | capture('abc(\d+)(\w+)', 2) }}

gives us

def