# ansible.builtin.regex_search
Search in a string to extract the part that matches the regular expression. Returns matched string or empty string if no match.

## Examples
```yml
# db => 'database42'
db: "{{ 'server1/database42' | regex_search('database[0-9]+') }}"

# Using inline regex flags instead of passing options to filter
# See https://docs.python.org/3/library/re.html for more information
# on inline regex flags
# server => 'sErver1'
db: "{{ 'sErver1/database42' | regex_search('(?i)server([0-9]+)') }}"

# drinkat => 'BAR'
drinkat: "{{ 'foo\nBAR' | regex_search('^bar', multiline=True, ignorecase=True) }}"
```