usage: useful to insert line in the rigth place in a file like:
Input:
foo o o foo bar a r
regex to insert “foobar” line after “foo” followed by “bar”
(?s)(.*?foo.*?\n)(bar.*)
substitution:
\1foobar\n\2
Result:
foo o o foo foobar bar a r
ref.: https://docs.python.org/2/library/re.html
"…
(?iLmsux)
(One or more letters from the set 'i'
, 'L'
, 'm'
, 's'
, 'u'
, 'x'
.) The group matches the empty string; the letters set the corresponding flags: re.I
(ignore case), re.L
(locale dependent), re.M
(multi-line), re.S
(dot matches all), re.U
(Unicode dependent), and re.X
(verbose), for the entire regular expression. (The flags are described in Module Contents.) This is useful if you wish to include the flags as part of the regular expression, instead of passing a flag argument to the re.compile()
function.
…"
(Note: I am pretty new with ansible, python and i am not english. So, no bashing will be apreciated… i am looking for a solution not useless comments)