title: Replace a string located between
body: <p>Here is my problem: in a variable that is text and contains commas, I try to delete only the commas located between two strings (in fact <code>[</code> and <code>]</code>). For example using the following string:</p>
  
  <pre><code>input =  "The sun shines, that's fine [not, for, everyone] and if it rains, it Will Be better."
  output = "The sun shines, that's fine [not for everyone] and if it rains, it Will Be better."
  </code></pre>
  
  <p>I know how to use <code>.replace</code> for the whole variable, but I can not do it for a part of it.
  There are some topics approaching on this site, but I did not manage to exploit them for my own question, e.g.: </p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/7098530/repeatedly-extract-a-line-between-two-delimiters-in-a-text-file-python">Repeatedly extract a line between two delimiters in a text file, Python</a> </li>
  <li><a href="https://stackoverflow.com/questions/4622472/python-finding-substring-between-certain-characters-using-regex-and-replace">Python finding substring between certain characters using regex and replace()</a> </li>
  <li><a href="https://stackoverflow.com/questions/6686711/replace-string-between-two-quotes">replace string between two quotes</a></li>
  </ul>