You can add the underscore to the list of allowed characters in the
regex_replace:
regex_replace('[^\d_.]+', '')
On Fri, May 8, 2015 at 5:03 PM, John Oliver <[email protected]> wrote:
> Nice! However, your regex is also killing the underscore, and I need
> that. I'm starting to monkey around with this, but I just don't know
> jinja, and I bet you'll have the right magic sauce before I can puzzle it
> out :-)
>
> Thanks!
>
> On Friday, May 8, 2015 at 2:45:21 PM UTC-7, Matt Martz wrote:
>>
>> Because I would rather use jinja2 than piping through a bunch of shell
>> commands:
>>
>> - name: Run java -version
>> command: java -version
>> register: java_version_out
>> changed_when: false
>>
>> - name: Set java_version var
>> set_fact: java_version="{{
>> java_version_out.stderr.splitlines()[0]|regex_replace('[^\d.]+', '') }}"
>>
>> - debug: var=java_version
>>
> --
> 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 post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/7663c0de-1184-420f-a572-2d9629589f36%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/7663c0de-1184-420f-a572-2d9629589f36%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
--
Matt Martz
@sivel
sivel.net
--
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAD8N0v9qVR7gua2xcaHG9-NrqivsRYxksWDeixm_nTA1u2ZjvA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.