Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

29
LINES

< > BotCompany Repo | #1025705 // positionalTokenIndex2_matchAll

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3381L/22K).

1  
sbool positionalTokenIndex2_matchAll_debug;
2  
3  
// use "*" as wildcard
4  
static L<Matches> positionalTokenIndex2_matchAll(S pat, PositionalTokenIndex2 idx) {
5  
  LS tokPat = wordTok_plusAsterisk(pat);
6  
  // get raw list from index
7  
  LLS list = positionalTokenIndex2_filter(idx, tokPat);
8  
  if (positionalTokenIndex2_matchAll_debug)
9  
    print("positionalTokenIndex2_matchAll " + pat + " => " + list);
10  
  new L<Matches> out;
11  
  if (list == null) ret out;
12  
  int n = l(tokPat), nAsterisks = countAsteriskTokens(tokPat);
13  
  new Matches m;
14  
  m.m = new S[nAsterisks];
15  
  search: for (LS tok : list) {
16  
    int iVars = 0;
17  
    for (int i = 1; i < n; i += 2) {
18  
      S t = tokPat.get(i);
19  
      if (t.equals("*"))
20  
        m.m[iVars++] = tok.get(i);
21  
      else if (!eqic(t, tok.get(i)))
22  
        continue search;
23  
    }
24  
    out.add(m);
25  
    m = new Matches;
26  
    m.m = new S[nAsterisks];
27  
  }
28  
  ret out;
29  
}

Author comment

Began life as a copy of #1025699

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1025705
Snippet name: positionalTokenIndex2_matchAll
Eternal ID of this version: #1025705/8
Text MD5: 7d213f1f876ed260dbaaa32d3096ec89
Transpilation MD5: 152645dfadb8123eae453ebdff5a39f8
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-10-14 00:56:32
Source code size: 902 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 132 / 214
Version history: 7 change(s)
Referenced in: [show references]