protected String limitText(String text){
  int startIndex=0;
  int searchStart=0;
  if (startPattern != null) {
    Matcher startMatcher=startPattern.matcher(text);
    if (startMatcher.find()) {
      startIndex=startMatcher.start();
      searchStart=startMatcher.end();
    }
 else     if (!startMatchOptional) {
      return null;
    }
  }
  int endIndex=text.length();
  if (endPattern != null) {
    Matcher endMatcher=endPattern.matcher(text);
    if (endMatcher.find(searchStart)) {
      endIndex=endMatcher.start();
    }
 else     if (!endMatchOptional) {
      return null;
    }
  }
  if ((startIndex > 0) || (endIndex < text.length())) {
    return StringUtils.substring(text,startIndex,endIndex);
  }
 else {
    return text;
  }
}

protected String limitText ( String text ) { int startIndex = 0 ; int searchStart = 0 ; if ( startPattern != null ) { Matcher startMatcher = startPattern . matcher ( text ) ; if ( startMatcher . find ( ) ) { startIndex = startMatcher . start ( ) ; searchStart = startMatcher . end ( ) ; } else if ( ! startMatchOptional ) { return null ; } } int endIndex = text . length ( ) ; if ( endPattern != null ) { Matcher endMatcher = endPattern . matcher ( text ) ; if ( endMatcher . find ( searchStart ) ) { endIndex = endMatcher . start ( ) ; } else if ( ! endMatchOptional ) { return null ; } } if ( ( startIndex > 0 ) || ( endIndex < text . length ( ) ) ) { return StringUtils . substring ( text , startIndex , endIndex ) ; } else { return text ; } }
limits text based on the start and end pattern .
