title: How can I grep same format substrings within a long string by java regular expression?
body: <p>For example, I want to grep both <code>/css/screen/shared/styles.css</code> and <code>/css/screen/nol/styles.css</code> from this long string:</p>
  
  <pre><code>@import "/css/screen/shared/styles.css";
  @import "/css/screen/nol/styles.css";
  </code></pre>
  
  <p>Note that this long string contains 2 lines, it should look like this in java code: </p>
  
  <pre><code>String sentence = "@import \"/css/screen/nol/styles.css\";\n@import \"/css/screen/shared/styles.css\";";
  </code></pre>
  
  <p>So far, I have:</p>
  
  <pre><code>"@import\\s\"(.*?)\";\n"
  </code></pre>
  
  <p>it only identifies the "/css/screen/shared/styles.css", but ignores the "/css/screen/nol/styles.css".</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public static String getImportCSS(String sentence){
          String result = "";
          if(sentence.length() == 0) return null;
          if(sentence.indexOf("@import ") != -1){
              Pattern regex = Pattern.compile("@import\\s\"(.*)\";");
              Matcher regexMatcher = regex.matcher(sentence);
              if(regexMatcher.find()){
                  for(int i = 0; i &lt;= regexMatcher.groupCount(); i++){
                      result = regexMatcher.group(1);
                  }
              }
              return result;
          }
          return null;
      }
  </code></pre>
  
  <p>What am I doing wrong here? Thanks!</p>