title: Non matching number Regex in Qt
body: <p>I am working on a number parser for q Qt calculator. I have create a few regex in order to match with the different kinds of number:</p>
  <p>Rationnal : <code>^[+-]?\d+\/[+-]?\d+$</code></p>
  <p>Integer  : <code>^[+-]?\d+\.?0*$</code></p>
  <p>Real : <code>^[+-]?\d*\.0*[1-9][0-9]*$</code></p>
  <p>Complexe : <code>^[+-]?[0-9]*(\.[0-9]*|\/[+-]?[0-9]+)?\$[+-]?[0-9]*(\.[0-9]*|\/[+-]?[0-9]+)?$</code></p>
  <p>I try to use them with the following fuction on QString:</p>
  <h1>parser.h :</h1>
  <pre><code>     bool isRationnal(const QString s)
  {
      QRegExp ratioExp (&quot;^[+-]?\d+\/[+-]?\d+$&quot;);
      return ratioExp.exactMatch(s);
  }
  bool isInteger(const QString s)
  {
      QRegExp regExp (&quot;^[+-]?\d+\.?0*$&quot;);
      return regExp.exactMatch(s);
  }
  bool isReal(const QString s)
  {
      QRegExp regExp (&quot;^[+-]?\d*\.0*[1-9][0-9]*$&quot;);
      return regExp.exactMatch(s);
  }
  bool isComplex(const QString s)
  {
      QRegExp regExp (&quot;^[+-]?[0-9]*(\.[0-9]*|\/[+-]?[0-9]+)?\$[+-]?[0-9]*(\.[0-9]*|\/[+-]?[0-9]+)?$&quot;);
      return regExp.exactMatch(s);
  }
  bool isNumber(const QString s){
     bool ok=false;
     s.toInt(&amp;ok);
     return ok;
  }
  </code></pre>
  <hr />
  <h1>main.c :</h1>
  <pre><code>QString test =&quot;6/90&quot;;
      if(isReal(test))
          printf(&quot;real\n&quot;);
  
      if(isInteger(test))
          printf(&quot;Integer\n&quot;);
  
      if(isRationnal(test))
          printf(&quot;Rationnal\n&quot;);
  
      if(isNumber(test))
          printf(&quot;Number\n&quot;);
      else printf(&quot;et merde\n&quot;);
      QRegExp ratioExp (&quot;^[+-]?\d+\/[+-]?\d+$&quot;);
      QRegExp IntExp (&quot;^[+-]?\d+\.?0*$&quot;);
      QRegExp RealExp (&quot;^[+-]?\d*\.0*[1-9][0-9]*$&quot;);
      QRegExp CplxExp (&quot;^[+-]?[0-9]*(\.[0-9]*|\/[+-]?[0-9]+)?\$[+-]?[0-9]*(\.[0-9]*|\/[+-]?[0-9]+)?$&quot;);
      if(ratioExp.isValid())
          printf(&quot;ratio valide\n&quot;);
  
      if(IntExp.isValid())
          printf(&quot;int valide\n&quot;);
      if(RealExp.isValid())
          printf(&quot;real valide\n&quot;);
      if(CplxExp.isValid())
          printf(&quot;cplx valide\n&quot;);
  
      return 0;
  }
  </code></pre>
  <p>I tried to run this code with several QString which are numbers, but it usually fail. Especially : it doesn't mathc with number if there is only one caracter like test=&quot;4&quot;.</p>
  <p>Do you know why are those boolean function failing? Maybe I am using the wrong Qt function but after trying several this one looks like what I am searching for.</p>
  <p>Feel free to give constructive critism,</p>
  <p>Thank you very much,</p>
  <p>Théophile</p>