mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Add regex methods into java.lang.String. Add group index checking into
java.util.regex.Matcher
This commit is contained in:
parent
28251840ec
commit
78f4f7a1ff
|
@ -22,6 +22,7 @@ import org.teavm.classlib.java.util.TArrays;
|
|||
import org.teavm.classlib.java.util.TComparator;
|
||||
import org.teavm.classlib.java.util.THashMap;
|
||||
import org.teavm.classlib.java.util.TMap;
|
||||
import org.teavm.classlib.java.util.regex.TPattern;
|
||||
import org.teavm.dependency.PluggableDependency;
|
||||
import org.teavm.javascript.ni.InjectedBy;
|
||||
import org.teavm.javascript.ni.Rename;
|
||||
|
@ -613,4 +614,16 @@ public class TString extends TObject implements TSerializable, TComparable<TStri
|
|||
}
|
||||
return interned;
|
||||
}
|
||||
|
||||
public boolean matches(String regex) {
|
||||
return TPattern.matches(regex, this.toString());
|
||||
}
|
||||
|
||||
public String[] split(String regex) {
|
||||
return TPattern.compile(regex).split(this.toString());
|
||||
}
|
||||
|
||||
public String[] split(String regex, int limit) {
|
||||
return TPattern.compile(regex).split(this.toString(), limit);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -316,6 +316,10 @@ public final class TMatcher implements TMatchResult {
|
|||
*/
|
||||
@Override
|
||||
public String group(int group) {
|
||||
if (group < 0 || group > matchResult.groupCount()) {
|
||||
throw new IndexOutOfBoundsException("Index " + group + " if out of range [0; " +
|
||||
matchResult.groupCount() + ")");
|
||||
}
|
||||
return matchResult.group(group);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user