title: How to use a scanner to scan through floating point values?
body: <p>OK, so I am using a scanner recognize if the next token in the string is a floating point value or decimal value and if not it will scan character by character until a decimal or floating number is found.</p>
  
  <p>So if input is something like <code>12/35.6+=123.5.6</code> tokens should be found in this order. </p>
  
  <blockquote>
    <ol>
    <li>'12'</li>
    <li>'/'</li>
    <li>'35.6'</li>
    <li>'+'</li>
    <li>'='</li>
    <li>'123.5'</li>
    <li>'.6' (interpreted as 0.6 float)</li>
    </ol>
  </blockquote>
  
  <p>This is what I have so far. </p>
  
  <pre><code>Scanner interpreter = new Scanner(input);
  
      //Allows scanning of individual char tokens
      interpreter.useDelimiter("");
  
      Pattern integerPattern = Pattern.compile("\\d*(\\.\\d+)?");
  
      //read through input
      while (interpreter.hasNext()) {
  
          //determines if next token is a float/decimal
          if (interpreter.hasNext(integerPattern)) {
              //extract number token
              String strVal = interpreter.findInLine(integerPattern);
              float value = Float.parseFloat(strVal);
              tokenList.add(new Token(11, value));
  
          }
          else{
              //should mean the next token is not a decimal or float
              //scan over token char by char
          }
       }
  </code></pre>
  
  <p>The problem I am running into is when I input something like 123.4.5 which should catch the first token <code>123.4</code> handle it and then catch <code>.5</code> as the next token. However, right it stands now it catches <code>123.4</code> but then as it handles the next token <code>if (interpreter.hasNext(integerPattern))</code> returns false an reads the period as an individual char.</p>
  
  <p>Tokens will look like this</p>
  
  <blockquote>
    <ol>
    <li>'123.4'</li>
    <li>'.'</li>
    <li>'5'</li>
    </ol>
  </blockquote>