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

16
LINES

< > BotCompany Repo | #1030935 // match3_withIntsAndIDs - understands "*", "<int>" and "<id>"

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

Transpiled version (3473L) is out of date.

1  
sbool match3_withIntsAndIDs(S pat, S s, Matches m default null) {
2  
  LS tokPat = javaTokWithAllPlusAngleBrackets(pat);
3  
  S pat2 = joinMap(tokPat, t -> eqOneOf(t, "<int>", "<id>") ? "*" : t);
4  
  Matches m2 = m == null ? new Matches : m;
5  
  ifdef match3_withIntsAndIDs_debug
6  
    printVars_str match3_withInts(+pat2, +s);
7  
  endifdef
8  
  if (!match3(pat2, s, m2)) false;
9  
  LS vars = filter(codeTokens(tokPat), t -> eqOneOf(t, "<int>", "<id>", "*"));
10  
  for i over vars: {
11  
    if (eq(vars.get(i), "<int>") && !isInteger(m2.get(i))
12  
      || eq(vars.get(i), "<id>") && !isIdentifier(m2.get(i)))
13  
      false;
14  
  }
15  
  true;
16  
}

Author comment

Began life as a copy of #1030933

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030935
Snippet name: match3_withIntsAndIDs - understands "*", "<int>" and "<id>"
Eternal ID of this version: #1030935/4
Text MD5: 67e667294db2ff0504d7b8f00d7e392c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-04-12 17:40:51
Source code size: 623 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 89 / 150
Version history: 3 change(s)
Referenced in: [show references]