Welcome to WebmasterWorld Guest from 34.231.247.139

Forum Moderators: open

Message Too Old, No Replies

problem in string breaking using javascript

string break in javascript, string break, explode string in javascript,

     
7:49 am on Jan 31, 2008 (gmt 0)

New User

10+ Year Member

joined:Jan 26, 2008
posts: 5
votes: 0


I am using the substr() and substring() javascript both functions in my code I have to choose the extenssion of file.
I am using it as:
1 - form.field.value.substr(-3);
2 - form.field.value.substring(-3);

it is working in firefox but not working in IE-5,6.

Please help me thanks.

4:28 pm on Jan 31, 2008 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Oct 17, 2005
posts:5021
votes: 26


substr(start, length)
substr can take a negative number as the start index. -1 specifies the last character, -2 the second-to-last character, and so on.

substring(from, to)
substring takes an integer that specifies the position within the string of the first character of the substring. It must be between 0 and the string length - 1.

Therefore, substring(-3) is not valid use of substring.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members