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

13
LINES

< > BotCompany Repo | #1031634 // jextractAll_any - find multiple patterns

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3522L/21K).

1  
static LS jextractAll_any(S s, S... patterns) {
2  
  ret jextractAll_any(javaTok(s), patterns);
3  
}
4  
5  
static LS jextractAll_any(LS tok, S... patterns) {
6  
  new TreeSet<Pair<Int>> set; // pair(startIndex, endIndex)
7  
  for (S pat : patterns) {
8  
    LS tokPat = javaTok(pat);
9  
    jfind_preprocess(tokPat);
10  
    set.addAll(map(jfindAll(tok, tokPat), i -> pair(i, i+l(tokPat)-2)));
11  
  }
12  
  ret mapPairsToList(set, (start, end) -> joinSubList(tok, start, end));
13  
}

Author comment

Began life as a copy of #1027860

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031634
Snippet name: jextractAll_any - find multiple patterns
Eternal ID of this version: #1031634/1
Text MD5: e8d4f6cb584f09d25a8e4255eaa67ed5
Transpilation MD5: 0e1fa64967f8ee79aba5064af4f3fa28
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-24 18:04:48
Source code size: 459 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 82 / 121
Referenced in: [show references]