title: What is the Regex for decimal numbers in Java?
body: <p>I am not quite sure of what is the correct regex for the period in Java. Here are some of my attempts. Sadly, they all meant any character.</p>
  
  <pre><code>String regex = "[0-9]*[.]?[0-9]*";
  String regex = "[0-9]*['.']?[0-9]*";
  String regex = "[0-9]*["."]?[0-9]*";
  String regex = "[0-9]*[\.]?[0-9]*";
  String regex = "[0-9]*[\\.]?[0-9]*";
  String regex = "[0-9]*.?[0-9]*";
  String regex = "[0-9]*\.?[0-9]*";
  String regex = "[0-9]*\\.?[0-9]*";
  </code></pre>
  
  <p>But what I want is the actual "." character itself. Anyone have an idea?</p>
  
  <p>What I'm trying to do actually is to write out the regex for a non-negative real number (decimals allowed). So the possibilities are: 12.2, 3.7, 2., 0.3, .89, 19</p>
  
  <pre><code>String regex = "[0-9]*['.']?[0-9]*";
  Pattern pattern = Pattern.compile(regex);
  
  String x = "5p4";
  Matcher matcher = pattern.matcher(x);
  System.out.println(matcher.find());
  </code></pre>
  
  <p>The last line is supposed to print false but prints true anyway. I think my regex is wrong though.</p>