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)

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

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: 351 / 395
Referenced in: [show references]