. titlesource: --> getHTMLComments - returns them without the enclosing <!-- and --> [1028644]

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

17
LINES

< > BotCompany Repo | #1028644 // getHTMLComments - returns them without the enclosing <!-- and -->

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

Libraryless. Click here for Pure Java version (2586L/16K).

1  
static LS getHTMLComments(S html) {
2  
  ret getHTMLComments(htmlTok(html));
3  
}
4  
5  
static LS getHTMLComments(LS tok) {
6  
  new LS l;
7  
  for (int idx = 0; idx < l(tok); idx += 2) {
8  
    S t = tok.get(idx);
9  
    int i = 0;
10  
    while ((i = indexOf(t, "<!--", i)) >= 0) {
11  
      int j = smartIndexOf(t, "-->", i+4);
12  
      l.add(substring(t, i+4, j));
13  
      i = j+3;
14  
    }
15  
  }
16  
  ret l;
17  
}

Author comment

Began life as a copy of #1008452

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1028644
Snippet name: getHTMLComments - returns them without the enclosing <!-- and -->
Eternal ID of this version: #1028644/4
Text MD5: eb2c2ac73b7d2202999fec2d4d394b73
Transpilation MD5: 859b9e098aef8530ab8750ab75274b94
Author: stefan
Category: javax / html parsing
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-01 11:56:56
Source code size: 386 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 197 / 304
Version history: 3 change(s)
Referenced in: [show references]