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).

sbool positionalTokenIndex2_matchAll_debug;

// use "*" as wildcard
static L<Matches> positionalTokenIndex2_matchAll(S pat, PositionalTokenIndex2 idx) {
  LS tokPat = wordTok_plusAsterisk(pat);
  // get raw list from index
  LLS list = positionalTokenIndex2_filter(idx, tokPat);
  if (positionalTokenIndex2_matchAll_debug)
    print("positionalTokenIndex2_matchAll " + pat + " => " + list);
  new L<Matches> out;
  if (list == null) ret out;
  int n = l(tokPat), nAsterisks = countAsteriskTokens(tokPat);
  new Matches m;
  m.m = new S[nAsterisks];
  search: for (LS tok : list) {
    int iVars = 0;
    for (int i = 1; i < n; i += 2) {
      S t = tokPat.get(i);
      if (t.equals("*"))
        m.m[iVars++] = tok.get(i);
      else if (!eqic(t, tok.get(i)))
        continue search;
    }
    out.add(m);
    m = new Matches;
    m.m = new S[nAsterisks];
  }
  ret out;
}

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: 121 / 201
Version history: 7 change(s)
Referenced in: [show references]