反斜杠中出现regex_replace错误

时间:2018-09-08 17:43:55

标签: ansible

使用Ansible剧本,我试图从url值中准确找出最后一部分。想出了以下剧本,但其给出了ERROR! Syntax Error while loading YAML

消息该如何纠正?

---
- hosts: example
  gather_facts: no
  vars:
    mystr: "This is the long string. With a url. http://example.org/12345"   
  pre_tasks:
    - name: Convert entered Symfony environment to lowercase
      set_fact:
        substr: "{{ mystr | regex_replace('^.*http:.*example.org\/(\d+).*?$', '\\1') }}"  
  tasks:
    - debug: 
        msg: "{{ substr }}"

谢谢 SR

0 个答案:

没有答案