1 | // We dropped the "***" support here (use match3 for that) |
2 | |
3 | static S[] find2(L<S> pat, L<S> tok) {
|
4 | for (int idx = 0; idx < tok.size(); idx += 2) { // TODO: subtract pat size from end index
|
5 | S[] result = find2(pat, tok, idx); |
6 | if (result != null) return result; |
7 | } |
8 | return null; |
9 | } |
10 | |
11 | static S[] find2(L<S> pat, L<S> tok, int idx) {
|
12 | if (idx+pat.size() > tok.size()) |
13 | return null; |
14 | new L<S> result; |
15 | for (int i = 1; i < pat.size(); i += 2) {
|
16 | S p = pat.get(i), t = tok.get(idx+i); |
17 | if (eq(p, "*")) |
18 | result.add(t); |
19 | else if (!p.equalsIgnoreCase(t)) |
20 | return null; |
21 | } |
22 | return toStringArray(result); |
23 | } |
Began life as a copy of #1000812
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1001234 |
| Snippet name: | find2 function |
| Eternal ID of this version: | #1001234/2 |
| Text MD5: | 0d8d8b14ab11ac47da5b83c18a65aeca |
| Author: | stefan |
| Category: | |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2019-11-13 13:47:29 |
| Source code size: | 654 bytes / 23 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 1122 / 2831 |
| Version history: | 1 change(s) |
| Referenced in: | [show references] |