On 2/26/21 5:12 PM, Pravin V wrote:
> Hello Everyone,
> When I use the regex_search in tasks, it is adding single quotes in the
> starting and end.
> Like for this -
> - sw01 GigabitEthernet0/0 IF-MIB.ifSpeed = 1000000000
> when I use regex_search-
> - name: SET FACT - Interface SPEED -1
> set_fact:
> speeds: "{{ item.0 | regex_search('[^=]*$') | regex_replace(' ', '') }}"
>
> Converting above value to -
> ok: [localhost] => (item=['sw01 GigabitEthernet0/0 IF-MIB.ifSpeed =
> 1000000000'])
>
> My goal is fetch the value after '='
> sw01 GigabitEthernet0/0 IF-MIB.ifSpeed = 1000000000
> to
> 1000000000
>
> please advise.
The regex_search filter is superfluous in this case, try:
regex_replace('^.*=(.*)$', '\\1')
\\1 references the part of the string matched by (.*).
Regards
Racke
>
> --
> 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]
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/4c18f52b-b989-4dca-945a-5272c8e6d60cn%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/4c18f52b-b989-4dca-945a-5272c8e6d60cn%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.
--
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/faa948ad-4922-21dd-cc9f-c24c68f21531%40linuxia.de.
OpenPGP_signature
Description: OpenPGP digital signature
