<awangdev>Decode String_3.java
public String expressionExpand(String s) {
        if (s == null || s.length() == 0) {
            return "";
        }
        StringBuffer sb = new StringBuffer();
        String substring = "";
        int number = 0;
        int paren = 0; 
        
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == '[') {
                if (paren > 0) { 
                    substring += c;
                }
                paren++;
            } else if (c == ']') {
                paren--;
                if (paren == 0) {
                    String innerString = expressionExpand(substring);
                    for (int num = 0; num < number; num++) {
                        sb.append(innerString);
                    }
                    number = 0;
                    substring = "";
                } else {
                    substring += c;
                }
            } else if (Character.isDigit(c)) {
                if (paren == 0) {
                    number = number * 10 + (c - '0');    
                } else {
                    substring += c;
                }
            } else  {
                if (paren == 0) {
                    sb.append(String.valueOf(c));    
                } else {
                    substring += c;
                }
            }
        }
        return sb.toString();
    }
public String sample_funcname ( String s ) {
  if ( s == null || s . length ( ) == 0 ) {
    return "" ;
  }
  StringBuffer sb = new StringBuffer ( ) ;
  String substring = "" ;
  int number = 0 ;
  int paren = 0 ;
  for ( int i = 0 ;
  i < s . length ( ) ;
  i ++ ) {
    char c = s . charAt ( i ) ;
    if ( c == '[' ) {
      if ( paren > 0 ) {
        substring += c ;
      }
      paren ++ ;
    }
    else if ( c == ']' ) {
      paren -- ;
      if ( paren == 0 ) {
        String innerString = expressionExpand ( substring ) ;
        for ( int num = 0 ;
        num < number ;
        num ++ ) {
          sb . append ( innerString ) ;
        }
        number = 0 ;
        substring = "" ;
      }
      else {
        substring += c ;
      }
    }
    else if ( Character . isDigit ( c ) ) {
      if ( paren == 0 ) {
        number = number * 10 + ( c - '0' ) ;
      }
      else {
        substring += c ;
      }
    }
    else {
      if ( paren == 0 ) {
        sb . append ( String . valueOf ( c ) ) ;
      }
      else {
        substring += c ;
      }
    }
  }
  return sb . toString ( ) ;
}
