1 | static class FRegExp extends FunctionImpl { |
2 | static boolean debug; |
3 | String re; |
4 | |
5 | *(String *re) {} |
6 | |
7 | public O process(Object _in) { |
8 | String in = cast _in; |
9 | Matcher matcher = Pattern.compile(re).matcher(in); |
10 | boolean found = matcher.find(); |
11 | if (debug) |
12 | debug("found: " + found + ", regexp: " + re); |
13 | if (found) |
14 | return matcher.group(1); |
15 | else |
16 | return ""; |
17 | } |
18 | |
19 | public void toJava_process(Code code) { |
20 | code.line("Matcher m = Pattern.compile(" + javaQuote(re) + ").matcher(" + code.s() + ");"); |
21 | code.assign("m.find() ? m.group(1) : \"\""); |
22 | } |
23 | } |
Began life as a copy of #1000584
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
ID | Author/Program | Comment | Date | |
---|---|---|---|---|
536 | #1000610 | Edit suggestion: !636 !629 main { static Object androidContext; static String programID; public static void main(String[] args) throws Exception { static class FRegExp extends FunctionImpl { static boolean debug; String re; *(String *re) {} public O process(Object _in) { String in = cast _in; Matcher matcher = Pattern.compile(re).matcher(in); boolean found = matcher.find(); if (debug) debug("found: " + found + ", regexp: " + re); if (found) return matcher.group(1); else return ""; } } }} | 2015-08-18 19:09:25 | delete |
522 | #1000604 (pitcher) | 2015-08-20 15:28:24 |
Snippet ID: | #1000622 |
Snippet name: | FRegExp |
Eternal ID of this version: | #1000622/1 |
Text MD5: | 46cffeb22c90f9edcb53766a037c7b2b |
Author: | stefan |
Category: | |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-08-22 00:39:03 |
Source code size: | 616 bytes / 23 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 1151 / 1525 |
Referenced in: | [show references] |