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

32
LINES

< > BotCompany Repo | #1008909 // ctxEvalPattern

JavaX fragment (include)

1  
sbool ctxEvalPattern_debug;
2  
3  
static bool ctxEvalPattern(S pat) {
4  
  ret ctxEvalPattern(pat, ctxContext().input);
5  
}
6  
7  
static bool ctxEvalPattern(S pat, S input) {
8  
  if (empty(pat)) true;
9  
  CtxContext c = ctxContext();
10  
  WoodyBot bot = woodyBot();
11  
  Pattern p = null;
12  
  if (bot != null)
13  
    p = bot.compiledPatterns.get(pat);
14  
  if (p == null) {
15  
    S pat2 = ctxExpandMacros(pat, c.regexpMacros);
16  
    S re = ctxREToJavaRE(pat2);
17  
    if (ctxEvalPattern_debug)
18  
      print("Java RE pattern: " + re);
19  
    p = compileRegexpIC(re);
20  
  }
21  
  if (bot != null)
22  
    bot.compiledPatterns.put(pat, p);
23  
  Matcher m = p.matcher(unnull(input));
24  
  //ctxContext().matches.clear();
25  
  if (m.find()) {
26  
    S group = m.group();
27  
    //print("Setting MATCH1=" + group);
28  
    listPut(c.matches, 0, group);
29  
    true;
30  
  }
31  
  false;
32  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1008909
Snippet name: ctxEvalPattern
Eternal ID of this version: #1008909/16
Text MD5: e8d3fef0af54b895e28b80c0867d8d6f
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-09-30 23:46:21
Source code size: 829 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 478 / 554
Version history: 15 change(s)
Referenced in: [show references]