You need to quote the entire jinja expression itself (including the
curlies) if you use it as a yaml value.
Because the single quotes are already using inside the expression,
you;'d have to use the double quotes:
tasks:
- debug:
msg: "Debug> {{ 'foo\nBAR' | regex_search('^bar',
multiline=True, ignorecase=True) }}"
On Tue, 31 Aug 2021 at 08:44, Dennis M <[email protected]> wrote:
>
> Hi,
>
> BTW, ansible-2.9.24-2.el7.
>
> "bar" instead of "BAR" was just a mistype.
> Double quote instead of single quote plays no role, i.e. this YAML:
>
> - hosts: monitor1p
> tasks:
> - debug:
> msg: Debug> {{ 'foo\nBAR' | regex_search('^bar', multiline=True,
> ignorecase=True) }}
>
> produces same output:
>
> ok: [monitor1p] => {
> "msg": "Debug> "
> }
>
> Regards,
>
>
> понедельник, 30 августа 2021 г. в 11:50:44 UTC+3, Antony Stone:
>>
>> On Monday 30 August 2021 at 10:37:53, Dennis M wrote:
>>
>> > Hi,
>> > I'm studying how to use regexp, and just follow documented examples,
>> > {{ 'foo\nBAR' | regex_search("^bar", multiline=True, ignorecase=True) }}
>> > expected result is: "bar".
>> > Instead of "bar" it gets an empty string.
>> > Is it a bug, or do I miss an important setting?
>>
>> See https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html
>> #searching-strings-with-regular-expressions
>>
>> and pay careful attention to details such as punctuation and case:
>>
>> 1. The example is:
>> {{ 'foo\nBAR' | regex_search('^bar', multiline=True, ignorecase=True) }}
>> instead, you used:
>> {{ 'foo\nBAR' | regex_search("^bar", multiline=True, ignorecase=True) }}
>>
>> 2. The expected result is:
>> # => 'BAR'
>> whereas you say:
>> expected result is: "bar".
>>
>> Try exactly what the example shows, and let us know if it does not produce
>> what the example should produce.
>>
>>
>> Antony.
>>
>> --
>> What is this talk of "software release"?
>> Our software evolves and matures until it is capable of escape, leaving a
>> bloody trail of designers and quality assurance people in its wake.
>>
>> Please reply to the list;
>> please *don't* CC me.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/8852b14e-1080-4383-a150-5cc32f545815n%40googlegroups.com.
--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAL8fbwOgxYLjMzHrRfQ_g0rdR8UGfX_PFNf7V%3D8vx3MjTzDNwg%40mail.gmail.com.