title: How to remove a string that includes specific strings but with different length inside the string?
body: <p>I have a log file that I want to delete some specific parts. The following shows a part of log file:</p>
  
  <pre><code>I0216 10:18:04.720626 31559 solver.cpp:273] Solving 
  I0216 10:18:04.720630 31559 solver.cpp:274] Learning Rate Policy: step
  I0216 10:18:05.242708 31559 solver.cpp:219] Iteration 0 (0 iter/s, 0.522037s/50 iters), loss = 1.60944
  I0216 10:18:05.242750 31559 solver.cpp:238]     Train net output #0: accuracy = 0
  I0216 10:18:05.242763 31559 solver.cpp:238]     Train net output #1: loss = 1.60944 (* 1 = 1.60944 loss)
  I0216 10:18:05.242785 31559 sgd_solver.cpp:105] Iteration 0, lr = 1e-10
  I0216 10:18:22.386440 31559 solver.cpp:219] Iteration 50 (2.91648 iter/s, 17.144s/50 iters), loss = 1.60944
  I0216 10:18:22.386497 31559 solver.cpp:238]     Train net output #0: accuracy = 0.643982
  I0216 10:18:22.386509 31559 solver.cpp:238]     Train net output #1: loss = 1.60944 (* 1 = 1.60944 loss)
  I0216 10:18:22.386515 31559 sgd_solver.cpp:105] Iteration 50, lr = 1e-10
  I0216 10:18:39.549926 31559 solver.cpp:219] Iteration 100 (2.91313 iter/s, 17.1637s/50 iters), loss = 1.60944
  I0216 10:18:39.550071 31559 solver.cpp:238]     Train net output #0: accuracy = 1
  I0216 10:18:39.550087 31559 solver.cpp:238]     Train net output #1: loss = 1.60944 (* 1 = 1.60944 loss)
  I0216 10:18:39.550093 31559 sgd_solver.cpp:105] Iteration 100, lr = 1e-10
  I0216 10:18:56.714752 31559 solver.cpp:219] Iteration 150 (2.91292 iter/s, 17.1649s/50 iters), loss = 1.60944
  I0216 10:18:56.714824 31559 solver.cpp:238]     Train net output #0: accuracy = 0.624222
  I0216 10:18:56.714838 31559 solver.cpp:238]     Train net output #1: loss = 1.60944 (* 1 = 1.60944 loss)
  I0216 10:18:56.714845 31559 sgd_solver.cpp:105] Iteration 150, lr = 1e-10
  I0216 10:19:13.893241 31559 solver.cpp:219] Iteration 200 (2.91059 iter/s, 17.1787s/50 iters), loss = 1.60944
  I0216 10:19:13.893450 31559 solver.cpp:238]     Train net output #0: accuracy = 1
  I0216 10:19:13.893467 31559 solver.cpp:238]     Train net output #1: loss = 1.60944 (* 1 = 1.60944 loss)
  I0216 10:19:13.893473 31559 sgd_solver.cpp:105] Iteration 200, lr = 1e-10
  I0216 10:19:31.094591 31559 solver.cpp:219] Iteration 250 (2.90674 iter/s, 17.2014s/50 iters), loss = 1.60944
  I0216 10:19:31.094650 31559 solver.cpp:238]     Train net output #0: accuracy = 0.61937
  I0216 10:19:31.094662 31559 solver.cpp:238]     Train net output #1: loss = 1.60944 (* 1 = 1.60944 loss)
  I0216 10:19:31.094667 31559 sgd_solver.cpp:105] Iteration 250, lr = 1e-10
  I0216 10:19:48.290045 31559 solver.cpp:219] Iteration 300 (2.90772 iter/s, 17.1956s/50 iters), loss = 1.60944
  I0216 10:19:48.290187 31559 solver.cpp:238]     Train net output #0: accuracy = 0.959229
  I0216 10:19:48.290205 31559 solver.cpp:238]     Train net output #1: loss = 1.60944 (* 1 = 1.60944 loss)
  I0216 10:19:48.290210 31559 sgd_solver.cpp:105] Iteration 300, lr = 1e-10
  I0216 10:20:05.504201 31559 solver.cpp:219] Iteration 350 (2.90457 iter/s, 17.2142s/50 iters), loss = 1.60944
  I0216 10:20:05.504257 31559 solver.cpp:238]     Train net output #0: accuracy = 0.772217
  I0216 10:20:05.504271 31559 solver.cpp:238]     Train net output #1: loss = 1.60944 (* 1 = 1.60944 loss)
  </code></pre>
  
  <p>As it can be seen, there are some lines that start with <code>31559 solver.cpp:219] Iteration</code>  </p>
  
  <p>I would like, without changing the other lines of the file, to change only these lines, for example, this one: FROM</p>
  
  <pre><code>   ... solver.cpp:219] Iteration 14750 (2.9004 iter/s, 17.239s/50 iters), loss = 1.60934
  </code></pre>
  
  <p>To</p>
  
  <pre><code>... solver.cpp:219] Iteration 14750, loss = 1.60934
  .
  .
  .
  </code></pre>
  
  <p>This means I want to remove the sub-string <code>(2.9004 iter/s, 17.239s/50 iters)</code> from the lines which includes the above-mentioned lines, but the other lines remain unchanged. 
  Thanks    </p>
  
  <p>I would like to remove those parts in a line that include <code>(2.8995 iter/s, 17.2444s/50 iters)</code>, the length of this string may differ from each other. This part starts with <code>(</code> and continues with a number (which may be different from the other line and continues with<code>iter/s,</code> and again a number and ends with <code>iters)</code>. </p>
  
  <p>AS @delca85 suggested the pattern is this:</p>
  
  <pre><code>p = "(\(\d*[.]?\d* iter/s\,\s\d*[.]?\d*)(s/[0-9]+)?(\siters\))"
  </code></pre>
  
  <p>Does anyone have a suggestion? Thanks in advance</p>