From 9a70dd1c94c819783e68a5b5363f729b0c1b8d8b Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Tue, 29 Apr 2014 16:53:52 -0400 Subject: [PATCH] Slight tweak to regex examples. --- docsite/rst/playbooks_variables.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docsite/rst/playbooks_variables.rst b/docsite/rst/playbooks_variables.rst index f09bce8e983..34bfb851261 100644 --- a/docsite/rst/playbooks_variables.rst +++ b/docsite/rst/playbooks_variables.rst @@ -304,12 +304,14 @@ To match strings against a regex, use the "match" or "search" filter:: url: "http://example.com/users/foo/resources/bar" tasks: - - debug: 'msg="Resource URI: {{ url }}"' + - shell: "msg='matched pattern 1'" when: url | match("http://example.com/users/.*/resources/.*") - - debug: 'msg="Resource path: {{ url }}"' + - debug: "msg='matched pattern 2'" when: url | search("/users/.*/resources/.*") +'match' will require a complete match in the string, while 'search' will require a match inside of the string. + To replace text in a string with regex, use the "regex_replace" filter:: # convert "ansible" to "able"