stringObject.substring (start, stop) for extracting the specified character string intermediary between the two subscripts.
start is necessary. A non-negative integer, a predetermined position of the first character of the substring to be extracted in the stringObject.
stop is optional. A non-negative integer, to extract the last character of the substring than a position in a multi stringObject. If omitted, then the substring will always return to the end of the string.
start from zero to stop (not included stop) does not accept the end of the negative parameter. Specified number of
stringObject.substr (start, length) may be drawn starting from the start index in the character string
start is necessary. To extract the substring starting index. It must be numeric. If it is negative, then the parameter declaration from the end of the string since the beginning of the position. That is, the value of -1 means the last character in the string, -2 means penultimate characters, and so on.
length optional. The number of characters in the string. It must be numeric. If this parameter is omitted, the return from the start position to the end stringObject string.
stringObject.slice (start, end) extracting a portion of the string, and return a new string portion extracted
start to be extracted fragment starting index. If it is negative, the predetermined parameter is counted from the end of the string to the start position. That is, the last character string refers -1, -2 means penultimate characters, and so on.
subscript ending end segment to be extracted immediately. If not specified, this parameter will have to start the extracted sub-string including a string to the end of the original string. If this parameter is negative, then it is prescribed begin to run from the end of the string position.
Returns new string comprising a string beginning at start stringObject (including start) end to end (not including the end) of all characters until the
If only one parameter N will be from the nth position Start returning to the remaining string (starting from 0)
String.slice ( String.substring () string.substr () var stringvalue = "Hello World"; Alert (StringValue.SLICE (3)); // "Lo World" Alert (StringValue.Substring (3)); // "Lo World "Alert (StringValue.Substr (3)); //" Lo World "Alert (StringValue.SLICE (3, 7)); //" Lo W "Alert (StringValue.Substring (3, 7)); //" Lo w "Alert (StringValue.Substr (3, 7)); //" Lo Worl "
If there are two parameters n, m, the slice and substring will return from the nth position to the second position (excluding the Mth position) String, and SubSTR returns M characters starting from the nth position.
String.slice () string.substring () string.substr () var stringvalue = “Hello World”; Alert (StringValue.Slice (-3)); / /”Rld”alert(StringValue.substrING (-3)); // “Hello World” Alert (StringValue.Substr (-3)); //”rld”alert(3 ,-4)); // “Lo W” Alert StringValue.substring (3, -4)); //”Hel”alert(3 ,-4)); // “” “(empty string)
When the parameter is a negative case, the slice adds the incoming negative value to the string length (SUBSTR), and the SubSTR adds the negative first argument with the string length, the second conversion to 0 Substring converts all negative values to 0.