| 915 | */ |
| 916 | // This is visible for testing. |
| 917 | List<String[]> findAllSubmatch(final String s, int n) { |
| 918 | final List<String[]> result = new ArrayList<String[]>(); |
| 919 | allMatches( |
| 920 | MachineInput.fromUTF16(s), |
| 921 | n, |
| 922 | new DeliverFunc() { |
| 923 | @Override |
| 924 | public void deliver(int[] match) { |
| 925 | String[] slice = new String[match.length / 2]; |
| 926 | for (int j = 0; j < slice.length; ++j) { |
| 927 | if (match[2 * j] >= 0) { |
| 928 | slice[j] = s.substring(match[2 * j], match[2 * j + 1]); |
| 929 | } |
| 930 | } |
| 931 | result.add(slice); |
| 932 | } |
| 933 | }); |
| 934 | if (result.isEmpty()) { |
| 935 | return null; |
| 936 | } |
| 937 | return result; |
| 938 | } |
| 939 | |
| 940 | /** |
| 941 | * {@code findAllSubmatchIndex} is the <a href='#all'>All</a> version of |