Reputation: 51
I am trying to split a string multiple spaces as delimiter in Ansible.
- name: Build Archive files 123.
set_fact:
archfilesloc: "{{ archfiles.split(\" +\")[1] }}" doesnt work
- name: Build Archive files 123.
set_fact:
archfilesloc: "{{ archfiles.split(\"\\s+\")[1] }}"doesnt work
- name: Build Archive files 123.
set_fact:
archfilesloc: "{{ archfiles.split(\"[\\s+]\")[1] }}" doesnt work
Upvotes: 4
Views: 2220
Reputation: 378
Try the following:
archfiles.split()[1]
Here, split()
is a Python function and behaves exactly like it does in python.
See: https://www.geeksforgeeks.org/python-string-split/
Upvotes: 3