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

17
LINES

< > BotCompany Repo | #1021768 // equalsSignsSections - requires at least two equals signs. returns prelude as ""

JavaX fragment (include)

1  
static SS equalsSignsSections(S text) {
2  
  LS lines = lines(text);
3  
  L<Int> l = indicesOfStartingWithTrim(lines, "==");
4  
  new LinkedHashMap<S> out;
5  
  if (nempty(l))
6  
    mapPutIfNemptyValue(out, "", rtrim(lines(subList(lines, 0, first(l))));
7  
  for i over l: {
8  
    int i1 = l.get(i);
9  
    int i2 = or(get(l, i+1), l(lines));
10  
    S heading = trim(lines.get(i1));
11  
    int iHeading = 0;
12  
    while (iHeading < l(heading) && heading.charAt(iHeading) == '=') iHeading++;
13  
    heading = trim(substring(heading, iHeading));
14  
    out.put(heading, lines(subList(lines, i1+1, i2)));
15  
  }
16  
  ret out;
17  
}

Author comment

Began life as a copy of #1021250

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1021768
Snippet name: equalsSignsSections - requires at least two equals signs. returns prelude as ""
Eternal ID of this version: #1021768/1
Text MD5: 551bd1d80aac08c7af44a9c47754482c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-02-26 10:46:46
Source code size: 598 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 171 / 207
Referenced in: [show references]