src/jdk/nashorn/internal/objects/NativeString.java
Print this page
*** 35,45 ****
import java.lang.invoke.MethodHandles;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
- import java.util.regex.Pattern;
import jdk.nashorn.internal.objects.annotations.Attribute;
import jdk.nashorn.internal.objects.annotations.Constructor;
import jdk.nashorn.internal.objects.annotations.Function;
import jdk.nashorn.internal.objects.annotations.Getter;
import jdk.nashorn.internal.objects.annotations.ScriptClass;
--- 35,44 ----
*** 604,614 ****
final NativeRegExp nativeRegExp;
if (string instanceof NativeRegExp) {
nativeRegExp = (NativeRegExp) string;
} else {
! nativeRegExp = new NativeRegExp(Pattern.compile(JSType.toString(string), Pattern.LITERAL));
}
if (replacement instanceof ScriptFunction) {
return nativeRegExp.replace(str, "", (ScriptFunction)replacement);
}
--- 603,613 ----
final NativeRegExp nativeRegExp;
if (string instanceof NativeRegExp) {
nativeRegExp = (NativeRegExp) string;
} else {
! nativeRegExp = NativeRegExp.flatRegExp(JSType.toString(string));
}
if (replacement instanceof ScriptFunction) {
return nativeRegExp.replace(str, "", (ScriptFunction)replacement);
}
*** 693,703 ****
return ((NativeRegExp) separator).split(str, lim);
}
// when separator is a string, it has to be treated as a
// literal search string to be used for splitting.
! return new NativeRegExp(Pattern.compile(JSType.toString(separator), Pattern.LITERAL)).split(str, lim);
}
/**
* ECMA B.2.3 String.prototype.substr (start, length)
*
--- 692,702 ----
return ((NativeRegExp) separator).split(str, lim);
}
// when separator is a string, it has to be treated as a
// literal search string to be used for splitting.
! return NativeRegExp.flatRegExp(JSType.toString(separator)).split(str, lim);
}
/**
* ECMA B.2.3 String.prototype.substr (start, length)
*