public static final String firstSegment(String segment) {
    	 	
    	segment = clean(segment);

    	Matcher segmentEndsInArrayMatcher = ARRAY_SYNTAX.matcher(segment);
        Matcher isArrayIndexMatcher = ARRAY_SYNTAX_PATTERN.matcher(segment);
    	
    	if(segmentEndsInArrayMatcher.matches()){
    		//my[0].dotted = returns my;
    		return segmentEndsInArrayMatcher.group(1);
    	}

    	if(isArrayIndexMatcher.matches()){
    		return isArrayIndexMatcher.group(1);
    	}
        
        int nextSegmentIndex = segment.indexOf(DOT);
        
        return nextSegmentIndex > NOT_FOUND ? clean(segment.substring(0, nextSegmentIndex)) : segment;
    }