title: Regular expression for editing yaml file
body: <p>I have the following configuration file <code>config.yml.example</code></p>
  
  <pre class="lang-yaml prettyprint-override"><code>development:
    key1: value1
    key2: value2
    key3: value3
  test:
    key1: value1
    key2: value2
    key3: value3
  production:
    key1: value1
    key2: value2
    key3: value3
  </code></pre>
  
  <p>I am trying to modify one of the keys in the production configuration using a bash script.</p>
  
  <pre class="lang-sh prettyprint-override"><code>for example_file in *.example; do
    if [ `basename ${example_file}` == "config.yml.example" ]; then
      sed -i '.bak' 's/\(.*key3:.*\)/key3: my_new_value/g' $example_file
    fi
    cp "$example_file" "$(basename "$example_file" .example)"
  done
  </code></pre>
  
  <p>The problem is <code>'s/\(.*key3:.*\)/key3: my_new_value/g'</code> is replacing the value of key3 under <code>development</code> and not <code>production</code>. 
  What would be the right regular expression to use in this case?</p>