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

20
LINES

< > BotCompany Repo | #1006254 // ocr_parseGroups - see: ocr_escapeMeaning

JavaX fragment (include)

static L<S> ocr_parseGroups(S s) {
  new L<S> l;
  for i over s:
    if (s.charAt(i) == '\\' && i+1 < l(s)) { // parse escaped character
      ++i;
      l.add(substring(s, i, i+1));
    } else if (s.charAt(i) == '[') { // parse group
      int j = i+1;
      new StringBuilder buf;
      while (j < l(s) && s.charAt(j) != ']') {
        if (s.charAt(j) == '\\' && j+1 < l(s)
          && eqOneOf(s.charAt(j+1), '[', ']')) ++j;
        buf.append(s.charAt(j++));
      }
      l.add(str(buf));
      i = j;
    } else
      l.add(substring(s, i, i+1));
  ret l;
}

Author comment

Began life as a copy of #1006107

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1006254
Snippet name: ocr_parseGroups - see: ocr_escapeMeaning
Eternal ID of this version: #1006254/1
Text MD5: 86ad8ac2275c178fe52dfa1466d4a0cb
Author: stefan
Category: javax / ocr
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-12-26 00:47:34
Source code size: 582 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 525 / 523
Referenced in: [show references]