Sounds like a job for regular expressions. Your example isn't self-consistent, so you'll have to define your requirements more clearly and adjust the regex to match.
The regex "(\\d{3})(\\d{2})?"
would match "111" or "11101", but not "1110" because the second capturing group (what you've called a "division") is not the required two digits. When a string matches, you would use Matcher#group(int)
to get the groups. For groups that weren't matched, it will return either null or an empty string depending on whether the expression in the group can match an empty string.