On Thu, 19 Mar 2020 14:19:26 +0530
Sivaraman P <[email protected]> wrote:

> Thank you for your response, this is giving output as below
> 
> \/ps/was-ps/woa/woa_runtime/profiles
> \/ps/was-ps/woa12/woa_runtime/profiles
> \/pas/ec1/ukpl/woa_runtime/profiles

The playbook below works for me

shell> cat playbook.yml
- hosts: localhost
  vars:
    mylines:
      - /ps/was-ps/woa/woa_runtime/profiles
      - /ps/was-ps/woa12/woa_runtime/profiles
      - /pas/ec1/ukpl/woa_runtime/profiles
  tasks:
    - debug:
        msg: "{{ mylines|map('regex_replace', myregex, myreplace)|list }}"
      vars:
        myregex: '^(.*?)woa(.*?)/(.*)$'
        myreplace: '\g<1>woa\g<2>/'

shell> ansible-playbook playbook.yml 
...
TASK [debug] ***
ok: [localhost] => {
    "msg": [
        "/ps/was-ps/woa/", 
        "/ps/was-ps/woa12/", 
        "/pas/ec1/ukpl/woa_runtime/"
    ]
}
...

HTH,
        -vlado

-- 
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/20200319113828.242940d8%40gmail.com.

Attachment: pgpanDMymAITW.pgp
Description: OpenPGP digital signature

Reply via email to