On Wed, 18 Mar 2020 08:20:19 -0700 (PDT) Sivaraman P <[email protected]> wrote:
> I have the output of command as below
>
> /ps/was-ps/woa/woa_runtime/profiles
> /ps/was-ps/woa12/woa_runtime/profiles
> /pas/ec1/ukpl/woa_runtime/profiles
>
> From this paths, I need to find the lines upto first occurence of woa or
> first occuerence of woa*.
>
> Output needed:
> /ps/was-ps/woa/
> /ps/was-ps/woa12/
> /pas/ec1/ukpl/woa_runtime/
>
> Is there anyway to do this in ansible regex_search or anyother filter.
Given the output lines are stored in the list "mylines", try this
- debug:
msg: "{{ mylines|
map('regex_replace', myregex, myreplace)|
list }}"
vars:
myregex: '^(.*?)woa(.*?)/(.*)$'
myreplace: '\g<1>woa\g<2>/'
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/20200318175246.21bd3d7a%40gmail.com.
pgp5SAMxytVBo.pgp
Description: OpenPGP digital signature
