public static int extractReference(String text){
  int lparenthIndex=text.indexOf('(');
  int spaceIndex=text.indexOf(' ');
  if (spaceIndex < 0) {
    spaceIndex=text.length();
  }
  if (lparenthIndex < 0) {
    return spaceIndex;
  }
 else {
    if (spaceIndex < lparenthIndex) {
      return spaceIndex;
    }
    int rparenthIndex=text.indexOf(')',lparenthIndex);
    if (rparenthIndex < 0) {
      rparenthIndex=text.length() - 1;
    }
    return rparenthIndex + 1;
  }
}

public static int extractReference ( String text ) { int lparenthIndex = text . indexOf ( '(' ) ; int spaceIndex = text . indexOf ( ' ' ) ; if ( spaceIndex < 0 ) { spaceIndex = text . length ( ) ; } if ( lparenthIndex < 0 ) { return spaceIndex ; } else { if ( spaceIndex < lparenthIndex ) { return spaceIndex ; } int rparenthIndex = text . indexOf ( ')' , lparenthIndex ) ; if ( rparenthIndex < 0 ) { rparenthIndex = text . length ( ) - 1 ; } return rparenthIndex + 1 ; } }
extracts a reference to a source element from the beginning of the text .
