Hi, instead of using regexes, you might want to use the XML module (https://docs.ansible.com/ansible/2.4/xml_module.html) with the xmlstring argument. That should allow you to do this in a much cleaner way.
Cheers, Felix > ansible 2.6.0 (devel da5cf72236) last updated 2018/02/14 14:29:49 > (GMT +200) > > The task seems obvious at first glance but it appears to be difficult > to implement in this context. > The string is: > host_meta: "<XRD > xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>\n <Link > rel='restconf' href='/restconf'/>\n</XRD>" > > I need to extract the values of rel and href into api_release and > api_root. I unsuccessfully tried the following: > - set_fact: api_release="{{ host_meta | regex_replace('^.* > rel=(.*) .*$', '\\1') }}" > when: host_meta is defined > > - set_fact: api_root="{{ host_meta | regex_replace('^.* > href=(.*)/>.*$', '\\1') }}" > when: host_meta is defined > > Both variables contain the whole string instead of the corresponding > substring, which should be: > api_release: 'restconf' > api_root: /restconf > > I have already successfully used this filter in other contexts. > What am I missing here? Is the filter confused by the string? > -- 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/20180214163823.3a305ebc%40utsjoki. For more options, visit https://groups.google.com/d/optout.
