<html> <body> <script type="text/javascript"> var str="W3Schools is great!" document.write(str.substr(2,6)) document.write("<br /><br />") document.write(str.substring(2,6)) </script> <p> The substr() method returns a specified part of a string. If you specify (2,6) the returned string will be from the second character (start at 0) and 6 long. </p> <p> The substring() method also returns a specified part of a string. If you specify (2,6) it returns all characters from the second character (start at 0) and up to, but not including, the sixth character. </p> </body> </html>
Edit the text above, and click on the button to see the result.
Copyright © 2007-2008, Www.JavaBasics.We.Bs All rights reserved.