On Thursday, March 14, 2019 at 7:39:47 PM UTC+6, Kai Stian Olstad wrote:
>
> On 14.03.2019 14:12, Ashok wrote: 
> > Hi, 
> > 
> > I've random paths like: 
> > 
> > /logs/other/dyn.log 
> > /logs/mx/mail.log 
> > /logs/apache-servers/other.log 
> > /logs/network/nas01.log 
> > /logs/mailouts/highvolume/mailout.log 
> > 
> > and many more. They are part of a `list` that is iterated over a loop. 
> > /logs/ will be common to all paths. I need to filter each item in the 
> > list 
> > so that, for eg, the last path looks like: 
> > 
> > mailouts_highvolume_mailout 
> > 
> > i.e. remove all forward slashes, logs and '.log' and concatenate rest 
> > with 
> > an underscore. 
>
> There are many way to do this, one of them is 
>
>    - debug: msg="{{ item | regex_replace('^/logs/(.*)\.log$', '\\1') | 
> regex_replace('/', '_') }}" 
>      with_items: 
>        - /logs/other/dyn.log 
>        - /logs/mx/mail.log 
>        - /logs/apache-servers/other.log 
>        - /logs/network/nas01.log 
>        - /logs/mailouts/highvolume/mailout.log 
>
> -- 
> Kai Stian Olstad 
>

-- 
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/d28eeee7-a834-4516-a624-e70ab576fe97%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to