mirror of https://github.com/ansible/ansible.git
adds two new regex filters for use in playbooks (#14696)
The first filter is regex_search which adds the ability to do a regex search on a fact. The filter supports returning either all capture groups or a set of capture groups (either by index or named). Example usage of regex_search filter debug: msg="{{ out.stdout[0] | regex_search('image version. (?P<test>\d+).(\d+)', '\\g<test>', '\\2' ) }}" The second filter is regex_findall with adds the capability to do a regex findall on a fact or variable and return all occurances of a pattern. debug: msg="{{ out.stdout[0] | regex_findall('vlan (\d+)' }}" The filter supports two addtional keyword arguments, ignorecase=[true, false] and multiline=[true, false]pull/15530/head
parent
776bffb52b
commit
9111efc975
Loading…
Reference in New Issue