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

29
LINES

< > BotCompany Repo | #1000657 // indexOfIgnoreCase

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (130L/1K).

// works on lists and strings and null

static int indexOfIgnoreCase(L<S> a, S b) {
  ret indexOfIgnoreCase(a, b, 0);
}

static int indexOfIgnoreCase(L<S> a, S b, int i) {
  int n = a == null ? 0 : a.size();
  for (; i < n; i++)
    if (eqic(a.get(i), b)) ret i;
  ret -1;
}

static int indexOfIgnoreCase(S[] a, S b, int i default 0) {
  int n = a == null ? 0 : a.length;
  for (; i < n; i++)
    if (eqic(a[i], b)) ret i;
  ret -1;
}

static int indexOfIgnoreCase(S a, S b) {
  ret indexOfIgnoreCase_manual(a, b);
  /*Matcher m = Pattern.compile(b, Pattern.CASE_INSENSITIVE + Pattern.LITERAL).matcher(a);
  if (m.find()) return m.start(); else ret -1;*/
}

static int indexOfIgnoreCase(S a, S b, int i) {
  ret indexOfIgnoreCase_manual(a, b, i);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 18 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, ishqpsrjomds, lnbujpyubztb, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney, xrpafgyirdlv

No comments. add comment

Snippet ID: #1000657
Snippet name: indexOfIgnoreCase
Eternal ID of this version: #1000657/14
Text MD5: 320c7c489a7f7a85e0ce6656719cf594
Transpilation MD5: 480dc970f01a25fbc3d923bfc178d95b
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-11-02 03:25:51
Source code size: 776 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 763 / 3464
Version history: 13 change(s)
Referenced in: [show references]