protected List<String> getRGroupsFromExtendedSmiles(String smiles) {
  String  extendedSmiles = getExtension(smiles);
    List<String> list = new ArrayList<>();
    if (extendedSmiles != null) {
      Integer currIndex = 0;
      char[] items = extendedSmiles.toCharArray();
      List<Integer> indexes = new ArrayList<Integer>();

      while (extendedSmiles.indexOf("_R", currIndex) > 0) {
        currIndex = extendedSmiles.indexOf("_R", currIndex);
        indexes.add(currIndex);
        currIndex++;
      }

      for (int k = 0; k < items.length; k++) {
        if (items[k] == 'R') {
          indexes.add(currIndex + k);
          currIndex++;
        }
      }

      String[] tokens = extendedSmiles.split("R", -1);
      if (tokens.length > 1) {
        for (int i = 1; i < tokens.length; i++) {
          String token = tokens[i];
          char[] chars = token.toCharArray();
          String numbers = "";
          for (int j = 0; j < chars.length; j++) {
            String letter = String.valueOf(chars[j]);
            if (letter.matches("[0-9]")) {
              numbers += letter;
            } else {
              break;
            }
          }

          if (numbers.length() > 0) {
            list.add("R" + numbers);
          }
        }
      }
    }
    
    if(extendedSmiles == null){
    	Pattern pattern = Pattern.compile("\\[\\*:([1-9]\\d*)\\]|\\[\\w+:([1-9]\\d*)");
    	Matcher matcher = pattern.matcher(smiles);

  	  
  	  while(matcher.find()){
  		  String info = "";
  		  if(matcher.group(1) != null){
  			  info = matcher.group(1);
  		  }
  		  if(matcher.group(2) != null){
  			  info = matcher.group(2);
  		  }
  		  
  		  list.add("R" + info);
  	  }
    }

    return list;
  }
protected List < String > getRGroupsFromExtendedSmiles ( String smiles ) { String extendedSmiles = getExtension ( smiles ) ; List < String > list = new ArrayList < > ( ) ; if ( extendedSmiles != null ) { Integer currIndex = 0 ; char [ ] items = extendedSmiles . toCharArray ( ) ; List < Integer > indexes = new ArrayList < Integer > ( ) ; while ( extendedSmiles . indexOf ( "_R" , currIndex ) > 0 ) { currIndex = extendedSmiles . indexOf ( "_R" , currIndex ) ; indexes . add ( currIndex ) ; currIndex ++ ; } for ( int k = 0 ; k < items . length ; k ++ ) { if ( items [ k ] == 'R' ) { indexes . add ( currIndex + k ) ; currIndex ++ ; } } String [ ] tokens = extendedSmiles . split ( "R" , - 1 ) ; if ( tokens . length > 1 ) { for ( int i = 1 ; i < tokens . length ; i ++ ) { String token = tokens [ i ] ; char [ ] chars = token . toCharArray ( ) ; String numbers = "" ; for ( int j = 0 ; j < chars . length ; j ++ ) { String letter = String . valueOf ( chars [ j ] ) ; if ( letter . matches ( "[0-9]" ) ) { numbers += letter ; } else { break ; } } if ( numbers . length ( ) > 0 ) { list . add ( "R" + numbers ) ; } } } } if ( extendedSmiles == null ) { Pattern pattern = Pattern . compile ( "\\[\\*:([1-9]\\d*)\\]|\\[\\w+:([1-9]\\d*)" ) ; Matcher matcher = pattern . matcher ( smiles ) ; while ( matcher . find ( ) ) { String info = "" ; if ( matcher . group ( 1 ) != null ) { info = matcher . group ( 1 ) ; } if ( matcher . group ( 2 ) != null ) { info = matcher . group ( 2 ) ; } list . add ( "R" + info ) ; } } return list ; }
@param smiles  extended smiles
@return List containing all rgroups from the given smiles