There are several free online regular expression tools available that tell you the number of steps to match a regex pattern against a given set of inputs and also provide you valuable debug info. You should also write your unit test cases. Here is a list of some online tools that can be used:
- Use jshell available with Java 9 to quickly test your regex
- Use RegexMatchers, a utility class with static methods, to test your regex in JUnit; check http://matchers.jcabi.com/regex-matchers.html
- regex101.com
- www.regexplanet.com
- www.rexegg.com
- www.debuggex.com
- regexper.com
- regexbuddy.com (not free)
- Use the Java/JUnit regex-tester library from https://github.com/nickawatts/regex-tester