title: passing variable in the middle on the regex pattern
body: <p>i am writing python code to match a line against a set of lines, using regex.
  i want to pass variable to my regex.</p>
  
  <p>Below is the regex pattern that i have come up with where i am substituting my variable in the position where i need it to match
  But it is failing to match. however when i use the string directly in place of variable the regex is working fine.</p>
  
  <pre><code>vm_name = my_vm-84
  pattern = r'(vm\.cpu\.num_cores{.+name=)%s(.+}) (\d+)' %vm_name
  
  res = re.search(pattern, metric_data)
  </code></pre>
  
  <p>Here metric_data is string of lines as below :</p>
  
  <pre><code>vm.cpu.num_cores{cluster="Cluster",cluster_status="active",id="44242543-0000-4481-b494-164fd257d190",name="my_vm-84",unit="cores",workspace_id="0f2a0e8751554e92abcb35b82f2415b2"} 1
  vm.cpu.num_cores{cluster="Cluster",cluster_status="active",id="50084393-8b48-ac4d-013c-2c29a114565a",name="VM-Do-not-Delete",unit="cores",workspace_id=""} 2
  vm.cpu.num_cores{cluster="Cluster",cluster_status="active",id="5008842e-a4dd-1167-fc78-c3b2ec467f66",name="windows clone",unit="cores",workspace_id=""} 8
  vm.cpu.num_cores{cluster="Cluster",cluster_status="active",id="5008b125-dddf-d3b0-e2c3-13a64e32511a",name="Ubuntu_new",unit="cores",workspace_id="0f2a0e8751554e92abcb35b82f2415b2"} 1
  vm.cpu.num_cores{cluster="Cluster",cluster_status="active",id="9818eaf3-382f-4a64-ac7a-89cbc5c36262",name="Ubuntu-cloud-init",unit="cores",workspace_id="0f2a0e8751554e92abcb35b82f2415b2"} 1
  </code></pre>
  
  <p>any help in building my regex is appreciated</p>