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

7
LINES

< > BotCompany Repo | #1016637 // lineAroundIndex - find line at character index

JavaX fragment (include)

static S lineAroundIndex(S s, int i) {
  if (!(i >= 0 && i < l(s))) null;
  int j = i;
  while (i > 0 && !isLineBreak(s.charAt(i-1))) --i;
  while (j < l(s) && !isLineBreak(s.charAt(j))) ++j;
  ret substring(s, i, j);
}

Author comment

Began life as a copy of #1007430

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1016637
Snippet name: lineAroundIndex - find line at character index
Eternal ID of this version: #1016637/1
Text MD5: b8be7aefa214441f40ff2b6e912517cf
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-26 13:55:09
Source code size: 225 bytes / 7 lines
Pitched / IR pitched: No / No
Views / Downloads: 350 / 394
Referenced in: [show references]