title: Extracting decimal numbers from string with Python regex
body: <p>I tried this using re library of Python.
  From a file i get several lines that contains elements separated by bars ('|'). I put them in a list and what I need is to get the numbers inside in order to operate with them.</p>
  
  <p>This would be one of the strings I want to split:</p>
  
  <pre><code>&gt;&gt;print(line_input)
  &gt;&gt;[240, 7821, 0, 12, 605, 0, 3]|[1.5, 7881.25, 0, 543, 876, 0, 121]|[237, 761, 0, 61, 7, 605, 605]
  </code></pre>
  
  <p>and my intention is to form a vector with each of the elements between square brackets.</p>
  
  <p>I created this regular expression</p>
  
  <pre><code>&gt;&gt;test_pattern="\|\[(\d*(\.\d+)?), (\d*(\.\d+)?), (\d*(\.\d+)?)]"
  </code></pre>
  
  <p>but the results are a bit confusing. In particular, the result is</p>
  
  <pre><code>&gt;&gt;vectors = re.findall(test_pattern, line_input)
  
  &gt;&gt;print(vectors)
  &gt;&gt;[('240', '', '7821', '', '0', '', '12', '', '605', '', '0', '', '3', ''), ('1.5', '.5', '7881.25', '.25', '0', '', '0', '', '0', '', '0', '', '0', ''), ('23437', '', '76611', '', '0', '', '0', '', '0', '', '605', '', '605', '')]
  </code></pre>
  
  <p>I don´t understand where the white spaces come from nor why the decimal part gets duplicated. I know that I almost get it, at least, I´m sure it´s a small simple detail, but I don't get.</p>
  
  <p>Thank you very much in advance.</p>