How to filter string in Ansible using jinja2?

Hi Ansible experts,

`
{
“outcome” => “success”,
“result” => “running”
}
{
“outcome” => “success”,
“result” => 2160063879L
}

`

Please help to filter the string running and the numeric value 2160063879 from the above stdout output using jinja2 filter into two different variables.

Hello Saravanan,

Have you tried “Regular Expression Filters” (regex_search) ??

Hi Piyush,
Using the below Jinja2 filter, able to extract the value 2160063879L. However need to extract exact numeric value alone from sub String by eliminating the letter ‘L’ from the output. Any help much appreciated.

`

- set_fact:
    upTime: "{{ status.stdout.split()[-2] }}"
  delegate_to: localhost
  become: false
  become_user: awx
  when: status.rc | int == 0
  ignore_errors: yes

`

STANDARD OUTPUT
2160063879L