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

13
LINES

< > BotCompany Repo | #1014931 // hextracttag - extract a tag from HTML replace it with nothing

JavaX fragment (include)

// tag = tag name
// newTag = full new contents including outer tag
// replaces only one occurrence
// returns pair(new text, extracted tag)
static Pair<S> hextracttag(S html, S tag) {
  L<S> tok = htmlcoarsetok(html);
  L<L<S>> tags = findContainerTag(tok, tag);
  if (empty(tags)) ret pair(html, null);
  L<S> theTag = first(tags);
  L<S> actualTag = subList(theTag, 1, l(theTag)-1);
  S s = join(actualTag);
  ret pair(join(replaceSubList(cloneList(tok), actualTag, emptyList())), s);
}

Author comment

Began life as a copy of #1003267

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: #1014931
Snippet name: hextracttag - extract a tag from HTML replace it with nothing
Eternal ID of this version: #1014931/2
Text MD5: 08fed6fd2f0f18991a3d4c2dec4cc9cd
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-06 15:28:43
Source code size: 501 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 359 / 364
Version history: 1 change(s)
Referenced in: [show references]