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

52
LINES

< > BotCompany Repo | #1002429 // jfind(s, pattern) - returns C index

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

Libraryless. Click here for Pure Java version (5586L/31K).

static int jfind(S s, S in) {
  ret jfind(javaTok(s), in);
}

static int jfind(L<S> tok, S in) {
  ret jfind(tok, 1, in);
}

static int jfind(L<S> tok, int startIdx, S in) {
  ret jfind(tok, startIdx, in, (ITokCondition) null);
}

static int jfind(L<S> tok, S in, O condition) {
  ret jfind(tok, 1, in, condition);
}

static int jfind(L<S> tok, int startIndex default 1, S in, IIntPred condition) {
  ret jfind(tok, startIndex, in, tokCondition(condition));
}

static int jfind(L<S> tok, int startIndex default 1, S in, ITokCondition condition) {
  ret jfind(tok, startIndex, in, (O) condition);
}

static int jfind(L<S> tok, int startIdx, S in, O condition) {
  //LS tokin = jfind_preprocess(javaTok(in));
  ret jfind(tok, startIdx, javaTokForJFind_array(in), condition);
}

// assumes you preprocessed tokin
static int jfind(L<S> tok, L<S> tokin) {
  ret jfind(tok, 1, tokin);
}

static int jfind(L<S> tok, int startIdx, L<S> tokin) {
  ret jfind(tok, startIdx, tokin, null);
}

static int jfind(LS tok, int startIdx, S[] tokinC, O condition) {
  ret findCodeTokens(tok, startIdx, false, tokinC, condition);
}

static int jfind(LS tok, int startIdx, L<S> tokin, O condition) {
  ret jfind(tok, startIdx, codeTokensAsStringArray(tokin), condition);
}

static L<S> jfind_preprocess(L<S> tok) {
  for (S type : litlist("quoted", "id", "int"))
    replaceSublist(tok, ll("<", "", type, "", ">"), ll("<" + type + ">"));
  replaceSublist(tok, ll("\\", "", "*"), ll("\\*"));
  ret tok;
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1002429
Snippet name: jfind(s, pattern) - returns C index
Eternal ID of this version: #1002429/15
Text MD5: b8e414fcdfa4bfaa3d0ec3767954eec0
Transpilation MD5: 620cba9a52c983fd496546ea31c3a965
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-02-16 01:31:44
Source code size: 1533 bytes / 52 lines
Pitched / IR pitched: No / No
Views / Downloads: 960 / 1747
Version history: 14 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1006800 - rjfind - find last occurrence, returns C index
#1008943 - jmatch2 - with full functionality of jfind (<quoted> etc.)
#1014855 - jfindOneOf
#1023396 - jfind_any - returns C index. might not be efficient (always tries all the patterns)
#1028004 - jfind_range(s, pattern) - returns TokenRange (CNC)
#1032855 - jfind_upTo
#3000382 - Answer for ferdie (>> t = 1, f = 0)