Question: I wanted to create a pattern for my `matches` in groovy. The input should range from `0 to 100`, but accepts `decimal value`. I know that this is possible by using the `double` datatype, but as a requirement I need to set the datatype of this property as a `String` that's why I need to set up the correct pattern of the matches for the `String` for it to work properly. Possible input:

```
1) 1 - valid
2) 1.5301 - valid
3) 99.6732 - valid
4) 99.1 - valid
5) 100.1 - invalid
6) 100 - valid

```

Thank you so much!

Answer: 
This should work:

```
100(\.0+)?|([1-9]?[0-9])(\.[0-9]+)?

```
Amber has the correct regular expression

As a way of demonstrating this in Groovy, you can do:

```
def testcases = [
  [ '1',       true ],
  [ '1.5301',  true ],
  [ '99.6732', true ],
  [ '99.1',    true ],
  [ '100.1',   false ],
  [ '100',     true ],
]

testcases.each { val, result ->
  assert ( val ==~ /100(\.0+)?|([1-9]?[0-9])(\.[0-9]+)?/ ) == result
}

```

However, I would probably do something like:

```
testcases.each { val, result ->
  try {
    Double.parseDouble( val ).with {
      assert ( it >= 0 && it <= 100 ) == result
    }
  } catch( ex ) {
    assert result == false
  }
}

```

As checking ranges with a regular expression feels like a bit of a foolhardy route to take