Prevent empty range in char class error