title: Python splitting string to pieces then adjusting their results
body: <p>I am trying to make the code below work as intended. I got it to work to accept numbers, - sign for negative numbers and a dot sign for percision. But the code still allows for multiple - and . signs. And it doesn't check if it starts or ends with them.</p>
  
  <p>I want to only get numbers, - sign if its a negative value and only one dot if its a float.</p>
  
  <p>here is my code:</p>
  
  <pre><code># org_text = gets something from clipboard
  
  new_text = [x.strip() for x in org_text.split(',')]  # as you can see new_text is a list of strings
  
  if len(new_text) &gt; 1:
      text = re.compile(r'[^\d.-]+').sub('', new_text[0])
  </code></pre>
  
  <p>Later on I use the following for some adjustments:</p>
  
  <pre><code>text = text.lstrip(' .').rstrip('-. ')
  text = text[0] + text[1:].replace('-', '')
  </code></pre>
  
  <p>It doesnt do exactly what I want plus I believe there should be an easier way. I tried playing arround with the regex part but didnt do the trick either.</p>
  
  <p>Any help will be appreciated.</p>
  
  <p>Edit: I didn't make some parts clear. I use the re.compile and sub which you can see from the code. I am trying to check the clipboard text which come in org_text. Then I am seperating the values inside with the comma sign. I am only accepting the regex r'[^\d.-]+' chars and deleting the rest in that original string using ''. At this point I get everything working properly except what I mentioned in my original question. I can get more than one - and . signs AND I also get them in unproper places. That's the part I am trying to fix.</p>