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

32
LINES

< > BotCompany Repo | #1008909 // ctxEvalPattern

JavaX fragment (include)

sbool ctxEvalPattern_debug;

static bool ctxEvalPattern(S pat) {
  ret ctxEvalPattern(pat, ctxContext().input);
}

static bool ctxEvalPattern(S pat, S input) {
  if (empty(pat)) true;
  CtxContext c = ctxContext();
  WoodyBot bot = woodyBot();
  Pattern p = null;
  if (bot != null)
    p = bot.compiledPatterns.get(pat);
  if (p == null) {
    S pat2 = ctxExpandMacros(pat, c.regexpMacros);
    S re = ctxREToJavaRE(pat2);
    if (ctxEvalPattern_debug)
      print("Java RE pattern: " + re);
    p = compileRegexpIC(re);
  }
  if (bot != null)
    bot.compiledPatterns.put(pat, p);
  Matcher m = p.matcher(unnull(input));
  //ctxContext().matches.clear();
  if (m.find()) {
    S group = m.group();
    //print("Setting MATCH1=" + group);
    listPut(c.matches, 0, group);
    true;
  }
  false;
}

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: 477 / 552
Version history: 15 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)