title: Number NOT followed by variable (a letter) in Java regex
body: <p>I did not find an answer to my problem so I hope that we can solve it here! Let's say I have this string: </p>
  
  <pre><code>String string = "1 + 1555.0056q + 34.0g - 451-0.7855";
  </code></pre>
  
  <p>I want to define a regex that can find all the constants and NOT the coefficients. So I would like to find just 1,- 451 and -0.7855. So far I can find coefficients, but only if they are not at the end of the string, because my regex depends on them not having a letter after them and then a whitespace or "-" or "+". This is how it looks:</p>
  
  <pre><code>\\s*(\\-|\\+)\\s*\\d+\\.?\\d+[a-zA-Z]{0}(\\s|\\+|\\-)
  </code></pre>
  
  <p>I also tried:</p>
  
  <pre><code>\\s*(\\-|\\+)\\s*\\d+\\.?\\d+(!?[a-zA-Z])
  </code></pre>
  
  <p>which did not work at all! So, could you help me extract only the constants, even if they are at the end of the string? Explaining what the new parts that you add does would be very helpful :)</p>