2008/01/15 10:11
Two useful string functions - substr & substring
2008/01/15 10:11 in HTML, Javascript

Now a days, javascript is widely used for web 2.0 programming.
In this case both function is very useful for string related algorithm.
You can simple get the required part of the string with high performance provided by client PC's performance.
1) substr() method extracts a specified number of characters in a string, from a start index.
Syntax: string.substr(start, length);
Quick Notes aout substr:
If start is negative, Internet Explorer returns the whole string. That’s wrong! IE should use the last character in the string.
2) Substring() method extracts the chars in a string between two specified indexes.
Syntax: string.Substring(start, stop);
Quick Notes about Substring:
If start equals stop, it returns an empty string.
If stop is omitted, it extracts characters to the end of the string.
If either argument is less than 0 or is NaN, it is treated as if it were 0.
If either argument is greater than string’s length, either argument will use string’s length.
If start > stop, then Substring will swap those 2 arguments.
If stop is omitted, it extracts characters to the end of the string.
If either argument is less than 0 or is NaN, it is treated as if it were 0.
If either argument is greater than string’s length, either argument will use string’s length.
If start > stop, then Substring will swap those 2 arguments.
Another posts included in "HTML, Javascript"
| Javascript based Regular Expression Tester (0) | 2008/01/15 |
| Javascript based Browser Sniffing (0) | 2008/01/25 |
| How to include Javascript from anonther ? (0) | 2008/01/25 |
| Is there URLEncode function in Javascript ? (0) | 2007/10/11 |
| Move window (0) | 2007/09/07 |
| How to calculate page loading time ? (0) | 2007/09/07 |
| Number Of Vists (0) | 2007/09/07 |
| Add Message On Mouse Traling (0) | 2007/09/07 |
Trackback : Cannot send a trackbact to this post.
-
Subject different money making ideas
2010/01/29 03:02
moneyideas
-
Subject different money making ideas
2010/01/29 11:56
moneyideas
-
Subject different money making ideas
2010/01/31 16:43
moneyideas
Prev

Rss Feed