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

35
LINES

< > BotCompany Repo | #1021062 // Match all texts with all patterns

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 1059K of libraries. Click here for Pure Java version (11675L/63K).

!7

sclass Entry {
  S text, pattern;
  S grouping;
}

cmodule2 MatchAll > DynObjectTable<Entry> {
  S refTexts, refPatterns;
  int max = 1000;
  
  visualize {
    ret northAndCenter(withMargin(makeForm2(
      "Texts (CRUD field reference)" := dm_textField('refTexts),
      "Patterns (CRUD field reference)" := dm_textField('refPatterns),
      rThread calc
    )), super.visualize());
  }
  
  void calc enter {
    final LS texts = dm_crudCollectField_ref(refTexts);
    final LS patterns = dm_crudCollectField_ref(refPatterns);
    print("Have " + n2(texts, "text") + ", " + n2(patterns, "pattern"));
    final new L data;
    withCancelPoint(voidfunc(final CancelPoint cp) {
      for (fS s : texts)
        for (fS pat : patterns)
          flexMatchIC_iterate(pat, s, voidfunc(Matches m) {
            data.add(nu(Entry, text := s, pattern := pat, grouping := matchedAsteriskPatternToGrouping(pat, m)));
            if (l(data) >= max) cancelTo(cp);
          });
    });
    setData(data);
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1021062
Snippet name: Match all texts with all patterns
Eternal ID of this version: #1021062/8
Text MD5: 5dd4a42ad5fce7b1133ed0b37bf1adfb
Transpilation MD5: 35bb386a248a1ea7fdf3fa0b487bb3d8
Author: stefan
Category: javax / a.i.
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-03-31 13:16:18
Source code size: 1039 bytes / 35 lines
Pitched / IR pitched: No / No
Views / Downloads: 309 / 681
Version history: 7 change(s)
Referenced in: [show references]