From 767be93f77776aeb49e70b01121946ec909bc649 Mon Sep 17 00:00:00 2001 From: Evan Kaufman Date: Mon, 14 Aug 2017 14:25:08 -0700 Subject: [PATCH] Replace - Clarified regex docs (#26727) * Clarified docs regarding multiline mode and negated character sets Refs #26712 * Escaped newline --- lib/ansible/modules/files/replace.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/files/replace.py b/lib/ansible/modules/files/replace.py index 90ecbacb3ba..2c0f31f4850 100644 --- a/lib/ansible/modules/files/replace.py +++ b/lib/ansible/modules/files/replace.py @@ -40,12 +40,16 @@ options: - The regular expression to look for in the contents of the file. Uses Python regular expressions; see U(http://docs.python.org/2/library/re.html). - Uses multiline mode, which means C(^) and C($) match the beginning - and end respectively of I(each line) of the file. + Uses MULTILINE mode, which means C(^) and C($) match the beginning + and end of the file, as well as the beginning and end respectively + of I(each line) of the file. + - Does not use DOTALL, which means the C(.) special character matches + any character I(except newlines). A common mistake is to assume that + a negated character set like C([^#]) will also not match newlines. + In order to exclude newlines, they must be added to the set like C([^#\\n]). - Note that, as of ansible 2, short form tasks should have any escape sequences backslash-escaped in order to prevent them being parsed as string literal escapes. See the examples. - replace: required: false description: