Well, given the limits of your i for loop, which stops at 4, I'm not surprised at what you are describing. Wouldn't you want to loop over the entire input string? Wouldn't you use text.length() instead of a hard-coded value of 4? I'd also maybe make your subTable arrays static/const.

Give an example of the input/output you are receiving.