--
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/00b8d501-d0f1-470f-88e5-ebb6ddec2196n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/9420d0e1-4d34-4bb2-b61f-6820dbaef0a3n%40googlegroups.com.
---
- hosts: localhost
connection: local
gather_facts: no
vars:
path: /tmp/out.txt
original_line: Substitute "s~(src|href)=('|\")/((?!version).*)~$1=$2/version//$3~i"
new_version: v3.78.1
tasks:
# Helper task to escape the entire line
- debug: var=original_line|regex_escape
- replace:
path: "{{ path }}"
# This regexp has the verbatim output of the previous debug task, it is used to confirm a match
#regexp: Substitute\ "s\~\(src\|href\)=\('\|\\"\)/\(\(\?!version\)\.\*\)\~\$1=\$2/version//\$3\~i"$
# This is the same, but with the part before and after "version" in parenthesis
regexp: ^(Substitute\ "s\~\(src\|href\)=\('\|\\"\)/\(\(\?!version\)\.\*\)\~\$1=\$2/)version(//\$3\~i")$
replace: '\1{{ new_version }}\2'
~
~
regex_replace2.yml 18,18 All
"regex_replace2.yml" 27L, 807B written
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/3055f3ab-d6d9-4953-8da5-7c9c0caf9949n%40googlegroups.com.