title: Python regex for number with or without decimals using a dot or comma as separator?
body: <p>I'm just learning regex and now I'm trying to match a number which more or less represents this:</p>
  
  <pre><code>[zero or more numbers][possibly a dot or comma][zero or more numbers]
  </code></pre>
  
  <p>No dot or comma is also okay. So it should match the following:</p>
  
  <pre><code>1
  123
  123.
  123.4
  123.456
  .456
  123,  # From here it's the same but with commas instead of dot separators
  123,4
  123,456
  ,456
  </code></pre>
  
  <p>But it should not match the following:</p>
  
  <pre><code>0.,1
  0a,1
  0..1
  1.1.2
  100,000.99  # I know this and the one below are valid in many languages, but I simply want to reject these
  100.000,99
  </code></pre>
  
  <p>So far I've come up with <code>[0-9]*[.,][0-9]*</code>, but it doesn't seem to work so well:</p>
  
  <pre><code>&gt;&gt;&gt; import re
  &gt;&gt;&gt; r = re.compile("[0-9]*[.,][0-9]*")
  &gt;&gt;&gt; if r.match('0.1.'): print 'it matches!'
  ...
  it matches!
  &gt;&gt;&gt; if r.match('0.abc'): print 'it matches!'
  ...
  it matches!
  </code></pre>
  
  <p>I have the feeling I'm doing two things wrong: I don't use match correctly AND my regex is not correct. Could anybody enlighten me on what I'm doing wrong? All tips are welcome!</p>