224 lines
8.1 KiB
Java
224 lines
8.1 KiB
Java
package kotlin.text;
|
|
|
|
import d0.f0.n;
|
|
import d0.g0.h;
|
|
import d0.g0.i;
|
|
import d0.z.d.k;
|
|
import d0.z.d.m;
|
|
import d0.z.d.o;
|
|
import java.io.Serializable;
|
|
import java.util.Objects;
|
|
import java.util.Set;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.sequences.Sequence;
|
|
/* compiled from: Regex.kt */
|
|
public final class Regex implements Serializable {
|
|
public static final a i = new a(null);
|
|
private Set<? extends i> _options;
|
|
private final Pattern nativePattern;
|
|
|
|
/* compiled from: Regex.kt */
|
|
public static final class a {
|
|
public a(DefaultConstructorMarker defaultConstructorMarker) {
|
|
}
|
|
|
|
public static final int access$ensureUnicodeCase(a aVar, int i) {
|
|
Objects.requireNonNull(aVar);
|
|
return (i & 2) != 0 ? i | 64 : i;
|
|
}
|
|
|
|
public final String escape(String str) {
|
|
m.checkNotNullParameter(str, "literal");
|
|
String quote = Pattern.quote(str);
|
|
m.checkNotNullExpressionValue(quote, "Pattern.quote(literal)");
|
|
return quote;
|
|
}
|
|
}
|
|
|
|
/* compiled from: Regex.kt */
|
|
public static final class b implements Serializable {
|
|
private static final long serialVersionUID = 0;
|
|
private final int flags;
|
|
private final String pattern;
|
|
|
|
/* compiled from: Regex.kt */
|
|
public static final class a {
|
|
public a(DefaultConstructorMarker defaultConstructorMarker) {
|
|
}
|
|
}
|
|
|
|
static {
|
|
new a(null);
|
|
}
|
|
|
|
public b(String str, int i) {
|
|
m.checkNotNullParameter(str, "pattern");
|
|
this.pattern = str;
|
|
this.flags = i;
|
|
}
|
|
|
|
private final Object readResolve() {
|
|
Pattern compile = Pattern.compile(this.pattern, this.flags);
|
|
m.checkNotNullExpressionValue(compile, "Pattern.compile(pattern, flags)");
|
|
return new Regex(compile);
|
|
}
|
|
}
|
|
|
|
/* compiled from: Regex.kt */
|
|
public static final class c extends o implements Function0<MatchResult> {
|
|
public final /* synthetic */ CharSequence $input;
|
|
public final /* synthetic */ int $startIndex;
|
|
public final /* synthetic */ Regex this$0;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public c(Regex regex, CharSequence charSequence, int i) {
|
|
super(0);
|
|
this.this$0 = regex;
|
|
this.$input = charSequence;
|
|
this.$startIndex = i;
|
|
}
|
|
|
|
@Override // kotlin.jvm.functions.Function0
|
|
/* renamed from: invoke */
|
|
public final MatchResult mo1invoke() {
|
|
return this.this$0.find(this.$input, this.$startIndex);
|
|
}
|
|
}
|
|
|
|
/* compiled from: Regex.kt */
|
|
public static final /* synthetic */ class d extends k implements Function1<MatchResult, MatchResult> {
|
|
public static final d i = new d();
|
|
|
|
public d() {
|
|
super(1, MatchResult.class, "next", "next()Lkotlin/text/MatchResult;", 0);
|
|
}
|
|
|
|
public final MatchResult invoke(MatchResult matchResult) {
|
|
m.checkNotNullParameter(matchResult, "p1");
|
|
return matchResult.next();
|
|
}
|
|
}
|
|
|
|
/* JADX WARNING: Illegal instructions before constructor call */
|
|
public Regex(String str) {
|
|
this(r2);
|
|
m.checkNotNullParameter(str, "pattern");
|
|
Pattern compile = Pattern.compile(str);
|
|
m.checkNotNullExpressionValue(compile, "Pattern.compile(pattern)");
|
|
}
|
|
|
|
/* JADX WARNING: Illegal instructions before constructor call */
|
|
public Regex(String str, i iVar) {
|
|
this(r2);
|
|
m.checkNotNullParameter(str, "pattern");
|
|
m.checkNotNullParameter(iVar, "option");
|
|
Pattern compile = Pattern.compile(str, a.access$ensureUnicodeCase(i, iVar.getValue()));
|
|
m.checkNotNullExpressionValue(compile, "Pattern.compile(pattern,…nicodeCase(option.value))");
|
|
}
|
|
|
|
public Regex(Pattern pattern) {
|
|
m.checkNotNullParameter(pattern, "nativePattern");
|
|
this.nativePattern = pattern;
|
|
}
|
|
|
|
public static /* synthetic */ MatchResult find$default(Regex regex, CharSequence charSequence, int i2, int i3, Object obj) {
|
|
if ((i3 & 2) != 0) {
|
|
i2 = 0;
|
|
}
|
|
return regex.find(charSequence, i2);
|
|
}
|
|
|
|
public static /* synthetic */ Sequence findAll$default(Regex regex, CharSequence charSequence, int i2, int i3, Object obj) {
|
|
if ((i3 & 2) != 0) {
|
|
i2 = 0;
|
|
}
|
|
return regex.findAll(charSequence, i2);
|
|
}
|
|
|
|
private final Object writeReplace() {
|
|
String pattern = this.nativePattern.pattern();
|
|
m.checkNotNullExpressionValue(pattern, "nativePattern.pattern()");
|
|
return new b(pattern, this.nativePattern.flags());
|
|
}
|
|
|
|
public final MatchResult find(CharSequence charSequence, int i2) {
|
|
m.checkNotNullParameter(charSequence, "input");
|
|
Matcher matcher = this.nativePattern.matcher(charSequence);
|
|
m.checkNotNullExpressionValue(matcher, "nativePattern.matcher(input)");
|
|
return h.access$findNext(matcher, i2, charSequence);
|
|
}
|
|
|
|
public final Sequence<MatchResult> findAll(CharSequence charSequence, int i2) {
|
|
m.checkNotNullParameter(charSequence, "input");
|
|
if (i2 >= 0 && i2 <= charSequence.length()) {
|
|
return n.generateSequence((Function0) new c(this, charSequence, i2), (Function1) d.i);
|
|
}
|
|
StringBuilder M = c.d.b.a.a.M("Start index out of bounds: ", i2, ", input length: ");
|
|
M.append(charSequence.length());
|
|
throw new IndexOutOfBoundsException(M.toString());
|
|
}
|
|
|
|
public final MatchResult matchEntire(CharSequence charSequence) {
|
|
m.checkNotNullParameter(charSequence, "input");
|
|
Matcher matcher = this.nativePattern.matcher(charSequence);
|
|
m.checkNotNullExpressionValue(matcher, "nativePattern.matcher(input)");
|
|
return h.access$matchEntire(matcher, charSequence);
|
|
}
|
|
|
|
public final boolean matches(CharSequence charSequence) {
|
|
m.checkNotNullParameter(charSequence, "input");
|
|
return this.nativePattern.matcher(charSequence).matches();
|
|
}
|
|
|
|
public final String replace(CharSequence charSequence, String str) {
|
|
m.checkNotNullParameter(charSequence, "input");
|
|
m.checkNotNullParameter(str, "replacement");
|
|
String replaceAll = this.nativePattern.matcher(charSequence).replaceAll(str);
|
|
m.checkNotNullExpressionValue(replaceAll, "nativePattern.matcher(in…).replaceAll(replacement)");
|
|
return replaceAll;
|
|
}
|
|
|
|
public final String replace(CharSequence charSequence, Function1<? super MatchResult, ? extends CharSequence> function1) {
|
|
m.checkNotNullParameter(charSequence, "input");
|
|
m.checkNotNullParameter(function1, "transform");
|
|
int i2 = 0;
|
|
MatchResult find$default = find$default(this, charSequence, 0, 2, null);
|
|
if (find$default == null) {
|
|
return charSequence.toString();
|
|
}
|
|
int length = charSequence.length();
|
|
StringBuilder sb = new StringBuilder(length);
|
|
do {
|
|
m.checkNotNull(find$default);
|
|
sb.append(charSequence, i2, find$default.getRange().getStart().intValue());
|
|
sb.append((CharSequence) function1.invoke(find$default));
|
|
i2 = find$default.getRange().getEndInclusive().intValue() + 1;
|
|
find$default = find$default.next();
|
|
if (i2 >= length) {
|
|
break;
|
|
}
|
|
} while (find$default != null);
|
|
if (i2 < length) {
|
|
sb.append(charSequence, i2, length);
|
|
}
|
|
String sb2 = sb.toString();
|
|
m.checkNotNullExpressionValue(sb2, "sb.toString()");
|
|
return sb2;
|
|
}
|
|
|
|
public final Pattern toPattern() {
|
|
return this.nativePattern;
|
|
}
|
|
|
|
@Override // java.lang.Object
|
|
public String toString() {
|
|
String pattern = this.nativePattern.toString();
|
|
m.checkNotNullExpressionValue(pattern, "nativePattern.toString()");
|
|
return pattern;
|
|
}
|
|
}
|