Details
-
Bug
-
Status: Closed
-
Trivial
-
Resolution: Fixed
-
3.0.0-alpha-3, 2.5.3
Description
There is one non-deterministic use case of using type coercion from java.util.regex.Matcher to a boolean. It was initially reported on Stack Overflow - https://stackoverflow.com/q/52930876/2194470
And here is an example that shows the problem:
def pattern = /[a-z]+/ def input = 'abc' def matcher = input =~ pattern println matcher as Boolean println matcher as Boolean
Output:
true false
Solution:
This problem can be solved by replacing matcher.find() with matcher.find(0), so casting matcher to a boolean does not modify search index and always starts from the beginning.
I will create a pull request in couple of minutes.