Regex question ^[a-zA-Z0-9]{5,10}$

java, regex

Solution

Make it optional (match exactly one or zero times)

^([a-zA-Z0-9]{5,10})?$

Problem

The above regular expression (in Java) matches a string of alpha numeric characters of length between 5 and 10. How can I modify the above regular expression to match with the above requirements as well as matching with an empty string?

Original source