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

17
LINES

< > BotCompany Repo | #1011561 // ai_subst_web_charBasedReplace [ignores case]

JavaX fragment (include)

static S ai_subst_web_charBasedReplace(S webID, fS input) {
  int n = websMadeInThread();
  Web web = assertNotNull("Web not found: " + webID, ai_getWeb(webID));
  WebRelation rel = assertNotNull(web_findRelationNamed(web, "matches"));
  S pat = web_unquoted(rel.a), cmd = web_unquoted(rel.b);
  assertEquals("substitute * => * with *", pat);
  new Matches m;
  assertTrue(flexMatchIC(pat, cmd, m));
  S src = $1;
  fS var = $3;
  L<S> terms = unquoteAll(trimAll(splitAtJavaToken(m.get(1), ",")));
  O replacer = func(S s) { replaceIC(s, var, input) };
  src = (S) callF(replacer, src);
  terms = map(replacer, terms);
  ai_postTriple_multi(src, "see:", terms);
  ret nWebs(websMadeInThread()-n) + " made";
}

Author comment

Began life as a copy of #1011554

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: #1011561
Snippet name: ai_subst_web_charBasedReplace [ignores case]
Eternal ID of this version: #1011561/6
Text MD5: a0d8ca1e2d8b8c6e0e7b9e42e36188bf
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-11-26 20:52:34
Source code size: 724 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 424 / 437
Version history: 5 change(s)
Referenced in: [show references]