public boolean matches(String value, String pattern) {
		if(pattern.length() == 0) return pattern.length() == 0;
		
		char mainChar = pattern.charAt(0);
		char altChar = mainChar == 'a' ? 'b' : 'a';
		int size = value.length();
		
		int countOfMain = countOf(pattern, mainChar);
		int countOfAlt = pattern.length() - countOfMain;
		int firstAlt = pattern.indexOf(altChar);
		int maxMainSize = size / countOfMain;
		
		for (int mainSize = 1; mainSize <= maxMainSize; mainSize++) {
			int remainingLength = size - mainSize * countOfMain;
			String first = value.substring(0, mainSize);
			if (countOfAlt == 0 || remainingLength % countOfAlt == 0) {
				int altIndex = firstAlt * mainSize;
				int altSize = countOfAlt == 0 ? 0 : remainingLength / countOfAlt;
				String second = countOfAlt == 0 ? "" : value.substring(altIndex, altSize + altIndex);
				
				String cand = buildFromPattern(pattern, first, second);
				if (cand.equals(value)) {
					System.out.printf("a was %s, b was %s\n", first, second);
					return true;
				}
			}
		}
		
		return false;
	}