Hi Bob,

here my code I removed '^' still not working

- set_fact:
        console: "{{ current_show_run[0] | map('regex_search', qry, 
multiline=True | select('string') | list }}"
  vars:
       qry: '^line con.*\n\spassword'

On Monday, September 21, 2020 at 9:09:27 PM UTC+5:30 rhar...@umich.edu 
wrote:

> On Mon, Sep 21, 2020 at 11:29 AM rajtheco...@gmail.com <
> rajtheco...@gmail.com> wrote:
>
>> How to search multiple lines using regex in Ansible?
>>
>> I tried below pattern and it is not working
>>
>> regex: ^line con.*(?:\n^\s.*)
>>
>> line console 0
>>  password
>>
>
> I don't think you can use caret " ^ " in the middle of a regex.  It is 
> probably trying to match a literal ^ symbol and not finding it.  Try 
> removing the caret.
>
> -- 
> Bob Harold
>  
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/9c2575af-d511-463a-86d9-25407bc77fd3n%40googlegroups.com.

Reply via email to