private Set<Integer> getStringIds(Dex dex, Pattern pattern) {
    Set<Integer> stringIds = new HashSet<Integer>();
    int stringIndex = 0;
    for (String s : dex.strings()) {
      if (pattern.matcher(s).find()) {
        stringIds.add(stringIndex);
      }
      stringIndex++;
    }
    return stringIds;
  }
Prints usages to out. Returns the number of matches found.
android/android_framework/dex-maker/src/main/java/com/android/dx/command/grep/Grep.java