Web page Special effects string extraction function
Definitions and usage
The substring () method extracts characters from a string mediation between two specified subscripts.
return value
A new string that contains a substring of stringobject whose contents are all characters from the start to the stop-1, whose length is stop minus start.
In this case, we will use SUBSTRING () to extract some characters from the string:
<script language= "J Avascript
<!--
var myString = new String ("This is a test");
var mysubstring = mystring.substring (0,10);
document.write (' The characters of our we string, ' + myString);
document.write (', are: ' + mysubstring);
document.close ();
</script>
In this case, we'll use substring () Extracts some characters from a string:
<title>a simple page</title>
<script Language= "JavaScript"
<!--
Inptxt = "Hello there";
Alert (inptxt.substring (0, 5);
// --
</script>
<body>
</body>
Description
The substring returned by the substring () method includes the character at start, but does not include the character at the end.
If the argument start is equal to end, then the method returns an empty string (that is, the length 0). If start is larger than end, the method swaps the two parameters before extracting the substring.