mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Scribunto: Use Luaj for pattern-matching (instead of Java Regex) [#413]
This commit is contained in:
@@ -16,6 +16,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
package gplx;
|
||||
import gplx.core.strings.*; import gplx.langs.gfs.*;
|
||||
public class Int_ {
|
||||
// -------- BASELIB_COPY --------
|
||||
public static final String Cls_val_name = "int";
|
||||
public static final Class<?> Cls_ref_type = Integer.class;
|
||||
|
||||
@@ -37,6 +38,72 @@ public class Int_ {
|
||||
throw Err_.new_type_mismatch_w_exc(exc, int.class, obj);
|
||||
}
|
||||
}
|
||||
|
||||
public static String To_str(int v) {return new Integer(v).toString();}
|
||||
public static int Parse_or(String raw, int or) {
|
||||
// process args
|
||||
if (raw == null) return or;
|
||||
int raw_len = String_.Len(raw);
|
||||
if (raw_len == 0) return or;
|
||||
|
||||
// loop backwards from nth to 0th char
|
||||
int rv = 0, power_of_10 = 1;
|
||||
for (int idx = raw_len - 1; idx >= 0; idx--) {
|
||||
char cur = String_.CharAt(raw, idx);
|
||||
int digit = -1;
|
||||
switch (cur) {
|
||||
// numbers -> assign digit
|
||||
case '0': digit = 0; break; case '1': digit = 1; break; case '2': digit = 2; break; case '3': digit = 3; break; case '4': digit = 4; break;
|
||||
case '5': digit = 5; break; case '6': digit = 6; break; case '7': digit = 7; break; case '8': digit = 8; break; case '9': digit = 9; break;
|
||||
|
||||
// negative sign
|
||||
case '-':
|
||||
if (idx != 0) { // invalid if not 1st
|
||||
return or;
|
||||
}
|
||||
else { // is first; multiply by -1
|
||||
rv *= -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
// anything else
|
||||
default:
|
||||
return or;
|
||||
}
|
||||
rv += (digit * power_of_10);
|
||||
power_of_10 *= 10;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
public static int[] Log10Ary = new int[] {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, Int_.Max_value};
|
||||
public static int Log10AryLen = 11;
|
||||
public static int Log10(int v) {
|
||||
if (v == 0) return 0;
|
||||
int sign = 1;
|
||||
if (v < 0) {
|
||||
if (v == Int_.Min_value) return -9; // NOTE: Int_.Min_value * -1 = Int_.Min_value
|
||||
v *= -1;
|
||||
sign = -1;
|
||||
}
|
||||
int rv = Log10AryLen - 2; // rv will only happen when v == Int_.Max_value
|
||||
int bgn = 0;
|
||||
if (v > 1000) { // optimization to reduce number of ops to < 5
|
||||
bgn = 3;
|
||||
if (v > 1000000) bgn = 6;
|
||||
}
|
||||
for (int i = bgn; i < Log10AryLen; i++) {
|
||||
if (v < Log10Ary[i]) {rv = i - 1; break;}
|
||||
}
|
||||
return rv * sign;
|
||||
}
|
||||
|
||||
public static int DigitCount(int v) {
|
||||
int log10 = Log10(v);
|
||||
return v > -1 ? log10 + 1 : log10 * -1 + 2;
|
||||
}
|
||||
|
||||
// -------- TO_MIGRATE --------
|
||||
public static int Cast_or(Object obj, int or) {
|
||||
try {
|
||||
return (Integer)obj;
|
||||
@@ -55,23 +122,7 @@ public class Int_ {
|
||||
}
|
||||
|
||||
public static int Parse(String raw) {try {return Integer.parseInt(raw);} catch(Exception e) {throw Err_.new_parse_exc(e, int.class, raw);}}
|
||||
public static int Parse_or(String raw, int or) {
|
||||
if (raw == null) return or;
|
||||
int rawLen = String_.Len(raw); if (rawLen == 0) return or;
|
||||
int rv = 0, tmp = 0, factor = 1;
|
||||
for (int i = rawLen; i > 0; i--) {
|
||||
char c = String_.CharAt(raw, i - 1);
|
||||
switch (c) {
|
||||
case '0': tmp = 0; break; case '1': tmp = 1; break; case '2': tmp = 2; break; case '3': tmp = 3; break; case '4': tmp = 4; break;
|
||||
case '5': tmp = 5; break; case '6': tmp = 6; break; case '7': tmp = 7; break; case '8': tmp = 8; break; case '9': tmp = 9; break;
|
||||
case '-': rv *= -1; continue; // NOTE: note continue
|
||||
default: return or;
|
||||
}
|
||||
rv += (tmp * factor);
|
||||
factor *= 10;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
public static int By_double(double v) {return (int)v;}
|
||||
public static int By_hex_bry(byte[] src) {return By_hex_bry(src, 0, src.length);}
|
||||
@@ -99,7 +150,6 @@ public class Int_ {
|
||||
}
|
||||
|
||||
public static byte[] To_bry(int v) {return Bry_.new_a7(To_str(v));}
|
||||
public static String To_str(int v) {return new Integer(v).toString();}
|
||||
public static String To_str_fmt(int v, String fmt) {return new java.text.DecimalFormat(fmt).format(v);}
|
||||
public static String To_str_pad_bgn_space(int val, int reqd_len) {return To_str_pad(val, reqd_len, Bool_.Y, Byte_ascii.Space);} // EX: 1, 3 returns " 1"
|
||||
public static String To_str_pad_bgn_zero (int val, int reqd_len) {return To_str_pad(val, reqd_len, Bool_.Y, Byte_ascii.Num_0);} // EX: 1, 3 returns "001"
|
||||
@@ -190,31 +240,4 @@ public class Int_ {
|
||||
float product = ((float)v * multiplier); // WORKAROUND (DotNet): (int)((float)v * multiplier) returns 0 for 100 and .01f
|
||||
return (int)product;
|
||||
}
|
||||
|
||||
public static int[] Log10Ary = new int[] {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, Int_.Max_value};
|
||||
public static int Log10AryLen = 11;
|
||||
public static int Log10(int v) {
|
||||
if (v == 0) return 0;
|
||||
int sign = 1;
|
||||
if (v < 0) {
|
||||
if (v == Int_.Min_value) return -9; // NOTE: Int_.Min_value * -1 = Int_.Min_value
|
||||
v *= -1;
|
||||
sign = -1;
|
||||
}
|
||||
int rv = Log10AryLen - 2; // rv will only happen when v == Int_.Max_value
|
||||
int bgn = 0;
|
||||
if (v > 1000) { // optimization to reduce number of ops to < 5
|
||||
bgn = 3;
|
||||
if (v > 1000000) bgn = 6;
|
||||
}
|
||||
for (int i = bgn; i < Log10AryLen; i++) {
|
||||
if (v < Log10Ary[i]) {rv = i - 1; break;}
|
||||
}
|
||||
return rv * sign;
|
||||
}
|
||||
|
||||
public static int DigitCount(int v) {
|
||||
int log10 = Log10(v);
|
||||
return v > -1 ? log10 + 1 : log10 * -1 + 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,72 +25,10 @@ public class Int__tst {
|
||||
tst_XtoStr_PadLeft_Zeroes(-123 , 3, "-123"); // negative
|
||||
tst_XtoStr_PadLeft_Zeroes(-1234 , 3, "-1234"); // negative
|
||||
} void tst_XtoStr_PadLeft_Zeroes(int val, int zeros, String expd) {Tfds.Eq(expd, Int_.To_str_pad_bgn_zero(val, zeros));}
|
||||
@Test public void parseOr_() {
|
||||
tst_ParseOr("", -1); // empty
|
||||
tst_ParseOr("123", 123); // single
|
||||
tst_ParseOr("1a", -1); // fail
|
||||
} void tst_ParseOr(String raw, int expd) {Tfds.Eq(expd, Int_.Parse_or(raw, -1));}
|
||||
@Test public void Between() {
|
||||
tst_Between(1, 0, 2, true); // simple true
|
||||
tst_Between(3, 0, 2, false); // simple false
|
||||
tst_Between(0, 0, 2, true); // bgn true
|
||||
tst_Between(2, 0, 2, true); // end true
|
||||
} void tst_Between(int val, int lhs, int rhs, boolean expd) {Tfds.Eq(expd, Int_.Between(val, lhs, rhs));}
|
||||
@Test public void Xto_fmt() {
|
||||
tst_XtoStr_fmt(1, "1");
|
||||
tst_XtoStr_fmt(1000, "1,000");
|
||||
} void tst_XtoStr_fmt(int v, String expd) {Tfds.Eq(expd, Int_.To_str_fmt(v, "#,###"));}
|
||||
@Test public void Log10_pos() {
|
||||
tst_Log10(0, 0);
|
||||
tst_Log10(1, 0);
|
||||
tst_Log10(9, 0);
|
||||
tst_Log10(10, 1);
|
||||
tst_Log10(100, 2);
|
||||
tst_Log10(1000000, 6);
|
||||
tst_Log10(1000000000, 9);
|
||||
tst_Log10(Int_.Max_value, 9);
|
||||
}
|
||||
@Test public void Log10_neg() {
|
||||
tst_Log10(-1, 0);
|
||||
tst_Log10(-10, -1);
|
||||
tst_Log10(-100, -2);
|
||||
tst_Log10(-1000000, -6);
|
||||
tst_Log10(-1000000000, -9);
|
||||
tst_Log10(Int_.Min_value, -9);
|
||||
tst_Log10(Int_.Min_value + 1, -9);
|
||||
}
|
||||
void tst_Log10(int val, int expd) {Tfds.Eq(expd, Int_.Log10(val));}
|
||||
@Test public void DigitCount() {
|
||||
tst_DigitCount(0, 1);
|
||||
tst_DigitCount(9, 1);
|
||||
tst_DigitCount(100, 3);
|
||||
tst_DigitCount(-1, 2);
|
||||
tst_DigitCount(-100, 4);
|
||||
} void tst_DigitCount(int val, int expd) {Tfds.Eq(expd, Int_.DigitCount(val), Int_.To_str(val));}
|
||||
@Test public void Log10() {
|
||||
tst_Log10( 0, 0);
|
||||
tst_Log10( 1, 0);
|
||||
tst_Log10( 2, 0);
|
||||
tst_Log10( 10, 1);
|
||||
tst_Log10( 12, 1);
|
||||
tst_Log10( 100, 2);
|
||||
tst_Log10( 123, 2);
|
||||
tst_Log10( 1000, 3);
|
||||
tst_Log10( 1234, 3);
|
||||
tst_Log10( 10000, 4);
|
||||
tst_Log10( 12345, 4);
|
||||
tst_Log10( 100000, 5);
|
||||
tst_Log10( 123456, 5);
|
||||
tst_Log10( 1000000, 6);
|
||||
tst_Log10( 1234567, 6);
|
||||
tst_Log10( 10000000, 7);
|
||||
tst_Log10( 12345678, 7);
|
||||
tst_Log10( 100000000, 8);
|
||||
tst_Log10( 123456789, 8);
|
||||
tst_Log10( 1000000000, 9);
|
||||
tst_Log10( 1234567890, 9);
|
||||
tst_Log10(Int_.Max_value, 9);
|
||||
}
|
||||
@Test public void Xto_int_hex_tst() {
|
||||
Xto_int_hex("007C", 124);
|
||||
} void Xto_int_hex(String raw, int expd) {Tfds.Eq(expd, Int_.By_hex_bry(Bry_.new_a7(raw)));}
|
||||
|
||||
@@ -17,8 +17,17 @@ package gplx;
|
||||
import java.lang.*;
|
||||
import gplx.core.strings.*; import gplx.langs.gfs.*; import gplx.core.envs.*;
|
||||
public class String_ {
|
||||
// -------- BASELIB_COPY --------
|
||||
public static final Class<?> Cls_ref_type = String.class;
|
||||
public static final String Cls_val_name = "str" + "ing";
|
||||
public static final int Find_none = -1, Pos_neg1 = -1;
|
||||
public static final String Empty = "", Null_mark = "<<NULL>>", Tab = "\t", Lf = "\n", CrLf = "\r\n";
|
||||
|
||||
public static boolean Eq(String lhs, String rhs) {return lhs == null ? rhs == null : lhs.equals(rhs);}
|
||||
public static int Len(String s) {return s.length();}
|
||||
public static char CharAt(String s, int i) {return s.charAt(i);}
|
||||
|
||||
public static String new_u8(byte[] v) {return v == null ? null : new_u8(v, 0, v.length);}
|
||||
public static String new_u8(byte[] v, int bgn, int end) {
|
||||
try {
|
||||
return v == null
|
||||
@@ -28,10 +37,62 @@ public class String_ {
|
||||
catch (Exception e) {Err_.Noop(e); throw Err_.new_("core", "unsupported encoding", "bgn", bgn, "end", end);}
|
||||
}
|
||||
|
||||
public static final Class<?> Cls_ref_type = String.class;
|
||||
public static final String Cls_val_name = "str" + "ing";
|
||||
public static final int Find_none = -1, Pos_neg1 = -1;
|
||||
public static final String Null = null, Empty = "", Null_mark = "<<NULL>>", Tab = "\t", Lf = "\n", CrLf = "\r\n";
|
||||
// use C# flavor ("a {0}") rather than Java format ("a %s"); also: (a) don't fail on format errors; (b) escape brackets by doubling
|
||||
private static final char FORMAT_ITM_LHS = '{', FORMAT_ITM_RHS = '}';
|
||||
public static String Format(String fmt, Object... args) {
|
||||
// method vars
|
||||
int args_len = Array_.Len_obj(args);
|
||||
if (args_len == 0) return fmt; // nothing to format
|
||||
int fmt_len = Len(fmt);
|
||||
|
||||
// loop vars
|
||||
int pos = 0; String arg_idx_str = ""; boolean inside_brackets = false;
|
||||
String_bldr bfr = String_bldr_.new_();
|
||||
while (pos < fmt_len) { // loop over every char; NOTE: UT8-SAFE b/c only checking for "{"; "}"
|
||||
char c = CharAt(fmt, pos);
|
||||
if (inside_brackets) {
|
||||
if (c == FORMAT_ITM_LHS) { // first FORMAT_ITM_LHS is fake; add FORMAT_ITM_LHS and whatever is in arg_idx_str
|
||||
bfr.Add(FORMAT_ITM_LHS).Add(arg_idx_str);
|
||||
arg_idx_str = "";
|
||||
}
|
||||
else if (c == FORMAT_ITM_RHS) { // itm completed
|
||||
int args_idx = Int_.Parse_or(arg_idx_str, Int_.Min_value);
|
||||
String itm = args_idx != Int_.Min_value && Int_.Between(args_idx, 0, args_len - 1) // check (a) args_idx is num; (b) args_idx is in bounds
|
||||
? Object_.Xto_str_strict_or_empty(args[args_idx]) // valid; add itm
|
||||
: String_.Concat_any(FORMAT_ITM_LHS, arg_idx_str, FORMAT_ITM_RHS); // not valid; just add String
|
||||
bfr.Add(itm);
|
||||
inside_brackets = false;
|
||||
arg_idx_str = "";
|
||||
}
|
||||
else
|
||||
arg_idx_str += c;
|
||||
}
|
||||
else {
|
||||
if (c == FORMAT_ITM_LHS || c == FORMAT_ITM_RHS) {
|
||||
boolean pos_is_end = pos == fmt_len - 1;
|
||||
if (pos_is_end) // last char is "{" or "}" (and not inside_brackets); ignore and just ad
|
||||
bfr.Add(c);
|
||||
else {
|
||||
char next = CharAt(fmt, pos + 1);
|
||||
if (next == c) { // "{{" or "}}": escape by doubling
|
||||
bfr.Add(c);
|
||||
pos++;
|
||||
}
|
||||
else
|
||||
inside_brackets = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
bfr.Add(c);
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
if (Len(arg_idx_str) > 0) // unclosed bracket; add FORMAT_ITM_LHS and whatever is in arg_idx_str; ex: "{0"
|
||||
bfr.Add(FORMAT_ITM_LHS).Add(arg_idx_str);
|
||||
return bfr.To_str();
|
||||
}
|
||||
|
||||
// -------- TO_MIGRATE --------
|
||||
public static String cast(Object v) {return (String)v;}
|
||||
public static String as_(Object obj) {return obj instanceof String ? (String)obj : null;}
|
||||
public static String new_a7(byte[] v) {return v == null ? null : new_a7(v, 0, v.length);}
|
||||
@@ -43,7 +104,6 @@ public class String_ {
|
||||
}
|
||||
catch (Exception e) {throw Err_.new_exc(e, "core", "unsupported encoding");}
|
||||
}
|
||||
public static String new_u8(byte[] v) {return v == null ? null : new_u8(v, 0, v.length);}
|
||||
public static String new_u8__by_len(byte[] v, int bgn, int len) {
|
||||
int v_len = v.length;
|
||||
if (bgn + len > v_len) len = v_len - bgn;
|
||||
@@ -111,7 +171,6 @@ public class String_ {
|
||||
} while (true);
|
||||
return count;
|
||||
}
|
||||
public static boolean Eq(String lhs, String rhs) {return lhs == null ? rhs == null : lhs.equals(rhs);}
|
||||
public static boolean EqAny(String lhs, String... rhsAry) {
|
||||
for (int i = 0; i < rhsAry.length; i++)
|
||||
if (Eq(lhs, rhsAry[i])) return true;
|
||||
@@ -267,7 +326,6 @@ public class String_ {
|
||||
if (pos < 0 || pos >= String_.Len(s)) throw Err_.new_wo_type("String_.Insert failed; pos invalid", "pos", pos, "s", s, "toInsert", toInsert);
|
||||
return s.substring(0, pos) + toInsert + s.substring(pos);
|
||||
}
|
||||
public static String Format(String fmt, Object... args) {return Format_do(fmt, args);}
|
||||
public static String FormatOrEmptyStrIfNull(String fmt, Object arg) {return arg == null ? "" : Format(fmt, arg);}
|
||||
public static String Concat(char... ary) {return new String(ary);}
|
||||
public static String Concat(String s1, String s2, String s3) {return s1 + s2 + s3;}
|
||||
@@ -381,57 +439,6 @@ public class String_ {
|
||||
public static String[] SplitLines_any(String s) {return Split_do(s, Op_sys.Lnx.Nl_str(), true);}
|
||||
public static String[] Split_lang(String s, char c) {return s.split(Character.toString(c));}
|
||||
|
||||
static String Format_do(String s, Object[] ary) {
|
||||
int aryLength = Array_.Len_obj(ary); if (aryLength == 0) return s; // nothing to format
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
char bracketBgn = '{', bracketEnd = '}';
|
||||
String aryVal = null; char c, next;
|
||||
int pos = 0; int textLength = Len(s); String numberStr = ""; boolean bracketsOn = false;
|
||||
while (true) {
|
||||
if (pos == textLength) break;
|
||||
c = CharAt(s, pos);
|
||||
if (bracketsOn) { // mode=bracketsOn
|
||||
if (c == bracketBgn) { // first bracketBgn is fake; add bracketBgn and whatever is in numberStr
|
||||
sb.Add(bracketBgn).Add(numberStr);
|
||||
numberStr = "";
|
||||
}
|
||||
else if (c == bracketEnd) {
|
||||
int aryIdx = Int_.Parse_or(numberStr, Int_.Min_value);
|
||||
if (aryIdx != Int_.Min_value && Int_.Between(aryIdx, 0, aryLength - 1)) // check (a) aryIdx is num; (b) aryIdx is in bounds
|
||||
aryVal = Object_.Xto_str_strict_or_empty(ary[aryIdx]);
|
||||
else
|
||||
aryVal = String_.Concat_any(bracketBgn, numberStr, bracketEnd); // not valid, just add String
|
||||
sb.Add(aryVal);
|
||||
bracketsOn = false;
|
||||
numberStr = "";
|
||||
}
|
||||
else // char=anythingElse
|
||||
numberStr += c;
|
||||
}
|
||||
else { // mode=bracketsOff
|
||||
if (c == bracketBgn || c == bracketEnd) {
|
||||
boolean isEnd = pos == textLength - 1;
|
||||
if (isEnd)
|
||||
sb.Add(c);
|
||||
else {
|
||||
next = CharAt(s, pos + 1);
|
||||
if (next == c) { // "{{" or "}}": escape by doubling
|
||||
sb.Add(c);
|
||||
pos++;
|
||||
}
|
||||
else
|
||||
bracketsOn = true;
|
||||
}
|
||||
}
|
||||
else // char=anythingElse
|
||||
sb.Add(c);
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
if (Len(numberStr) > 0) // unclosed bracket; add bracketBgn and whatever is in numberStr; ex: "{0"
|
||||
sb.Add(bracketBgn).Add(numberStr);
|
||||
return sb.To_str();
|
||||
}
|
||||
static String[] Split_do(String s, String spr, boolean skipChar13) {
|
||||
if (String_.Eq(s, "") // "".Split('a') return array with one member: ""
|
||||
|| String_.Eq(spr, "")) // "a".Split('\0') returns array with one member: "a"
|
||||
|
||||
@@ -16,11 +16,6 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
package gplx;
|
||||
import org.junit.*;
|
||||
public class String__tst {
|
||||
@Test public void Len() {
|
||||
tst_Len("", 0);
|
||||
tst_Len("abc", 3);
|
||||
} void tst_Len(String v, int expd) {Tfds.Eq(expd, String_.Len(v), "Len");}
|
||||
|
||||
@Test public void LimitToFirst() {
|
||||
tst_LimitToFirst("abc", 0, "");
|
||||
tst_LimitToFirst("abc", 1, "a");
|
||||
@@ -120,20 +115,6 @@ public class String__tst {
|
||||
@Test public void Repeat() {
|
||||
Tfds.Eq("333", String_.Repeat("3", 3));
|
||||
}
|
||||
@Test public void Format() {
|
||||
tst_Format("", ""); // empty
|
||||
tst_Format("no args", "no args"); // no args
|
||||
tst_Format("0", "{0}", 0); // one
|
||||
tst_Format("0 and 1", "{0} and {1}", 0, 1); // many
|
||||
tst_Format("{", "{{", 0); // escape bracketBgn
|
||||
tst_Format("}", "}}", 0); // escape bracketEnd
|
||||
tst_Format("{a0c}", "{a{0}c}", 0); // nested;
|
||||
tst_Format("{a{b}c}", "{a{b}c}", 0); // invalid invalid
|
||||
tst_Format("{1}", "{1}", 1); // invalid array index
|
||||
tst_Format("{a} {b}", "{a} {b}", 0); // invalid many
|
||||
tst_Format("{a}0{b}1", "{a}{0}{b}{1}", 0, 1); // invalid and valid
|
||||
tst_Format("{0", "{0", 0); // invalid dangling
|
||||
} void tst_Format(String expd, String fmt, Object... ary) {Tfds.Eq(expd, String_.Format(fmt, ary));}
|
||||
@Test public void Split() {
|
||||
tst_Split("ab", " ", "ab"); // no match -> return array with original input
|
||||
tst_Split("ab cd", " ", "ab", "cd"); // separator.length = 1
|
||||
|
||||
@@ -16,17 +16,16 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
package gplx.langs.regxs; import gplx.*; import gplx.langs.*;
|
||||
public class Regx_adp_ {
|
||||
public static Regx_adp new_(String pattern) {return new Regx_adp(pattern);}
|
||||
public static List_adp Find_all(String input, String find) {
|
||||
Regx_adp regx = Regx_adp_.new_(find);
|
||||
int idx = 0;
|
||||
public static List_adp Find_all(String src, String pat) {
|
||||
int src_len = String_.Len(src);
|
||||
Regx_adp regx = Regx_adp_.new_(pat);
|
||||
int pos = 0;
|
||||
List_adp rv = List_adp_.New();
|
||||
while (true) {
|
||||
Regx_match match = regx.Match(input, idx);
|
||||
while (pos < src_len) {
|
||||
Regx_match match = regx.Match(src, pos);
|
||||
if (match.Rslt_none()) break;
|
||||
rv.Add(match);
|
||||
int findBgn = match.Find_bgn();
|
||||
idx = findBgn + match.Find_len();
|
||||
if (idx > String_.Len(input)) break;
|
||||
pos = match.Find_bgn() + match.Find_len();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user