String substr() and substring(): returns a specified part of a string : String « Language Basics « JavaScript DHTML

JavaScript DHTML
1. Ajax Layer
2. Data Type
3. Date Time
4. Development
5. Document
6. Dojo toolkit
7. Event
8. Event onMethod
9. Ext JS
10. Form Control
11. GUI Components
12. HTML
13. Javascript Collections
14. Javascript Objects
15. Javascript Properties
16. jQuery
17. Language Basics
18. Mochkit
19. Mootools
20. Node Operation
21. Object Oriented
22. Page Components
23. Rico
24. Scriptaculous
25. Security
26. SmartClient
27. Style Layout
28. Table
29. Utilities
30. Window Browser
31. YUI Library
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
JavaScript DHTML » Language Basics » String 
String substr() and substring(): returns a specified part of a string
  
/*

substr() returns a part of a string. substr(2,6) return from the second character (start at 0) and 6 long.
substring() returns a part of a string. substring(2,6) returns all characters from the second character (start at 0) and up to, but not including, the sixth character.

*/

<html>
<body>

<script type="text/javascript">
    var str="JavaScript is great!"
    document.write(str.substr(2,6))
    document.write("<br><br>")
    document.write(str.substring(2,6))
</script>

</body>
</html>


           
         
    
  
Related examples in the same category
1. Demo all String methods
2. String utility: word count, replace and capitalize
3. Strip Commas
4. Text Range Search and Replace (IE only)
5. Counting the Words in a Text String
6. Reversing a String
7. Trimming a String Using Regular Expressions
8. String encode and decode
9. Capitalizing the First Letter in Each Word of a String
10. Playing with Strings
11.  Using the String Object's Link Method
12. Using a for Loop to Reverse a String
13.  Concatenate JavaScript String
14. String length: number of characters in a string.
15. String fontcolor(): a string in a specified color
16. String indexOf(): string position
17. String Validation
18. Using Quotes within Strings
19. Using the String Object
20. String toUpperCase
21. Lab for string.replace() and string.search()
22. Slicing a String
23. A String Object Prototype
24. Creating a Custom toString() Method
25. Reading a Portion of a String
26. Source Code for a Sample Page That Formats a String Object with the 'a' Tag
27. Source Code for Our String-Formatting Script
28. Adding a replace() Method to the String Object
29. Creating a Function That Will Search and Replace in Strings
30.  Using the indexOf() Method to Find All Occurrences of the Letter e in a Sentence
31. Methods and Properties of the String Object
32. String match(): returns the text if found
33. String toLowerCase() and toUpperCase(): converts a string to lowercase and uppercase
34. Converting Strings to Upper Case
35. String encoder
36. Concatenate two string variables together
37. Search string value in an array
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.