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

27
LINES

< > BotCompany Repo | #1001876 // jmatch function (match with javaTok, keeps punctuation) - pattern goes first (unlike jfind). See also jmatch2

JavaX fragment (include)

1  
// DIFFERENCES to jfind: always ignores case, doesn't recognize <id> etc
2  
// You probably want jmatch2
3  
4  
static boolean jmatch(S pat, S s) {
5  
  return jmatch(pat, s, null);
6  
}
7  
8  
static boolean jmatch(S pat, S s, Matches matches) {
9  
  if (s == null) return false;
10  
  ret jmatch(pat, javaTok(s), matches);
11  
}
12  
13  
static boolean jmatch(S pat, L<S> toks) {
14  
  ret jmatch(pat, toks, null);
15  
}
16  
17  
static boolean jmatch(S pat, L<S> toks, Matches matches) {
18  
  L<S> tokpat = javaTok(pat);
19  
  S[] m = match2(tokpat, toks);
20  
  //print(structure(tokpat) + " on " + structure(toks) + " => " + structure(m));
21  
  if (m == null)
22  
    ret false;
23  
  else {
24  
    if (matches != null) matches.m = m;
25  
    ret true;
26  
  }
27  
}

Author comment

Began life as a copy of #1001104

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: #1001876
Snippet name: jmatch function (match with javaTok, keeps punctuation) - pattern goes first (unlike jfind). See also jmatch2
Eternal ID of this version: #1001876/7
Text MD5: d3df658ced648c9bd405fe91713ad24c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-09-11 22:54:59
Source code size: 704 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 682 / 928
Version history: 6 change(s)
Referenced in: [show references]