It shows that you are unregistered. Please register with us by clicking Here
![]() |
|
![]() |
![]() | Register - FAQ - Today's Posts - New Posts - Support - Search | ![]() |
|
|
#1 (permalink) |
|
Member
Join Date: Jul 2006
Age: 48
Posts: 45
|
Although string comparition allows you to find identical strings, it's sometimes more useful to check if a piece of text is part of a larger string, and to know exactly where that text is located within the string.
We can find a particular piece of text within a string using JavaScrip's indexOf method. This method takes one argument, the text you want to find and returns the index of that text: var a = "This sentance contains a substring."; var b = a.indexOf("sentance"); The value of the variable b is now 5. String index numbering starts at 0, so although the text "sentance" starts on the sixth character, it's index will be 5. If the text you're searching for doesn't occur in the string, the method will return an index of -1. |
|
|
|
|
|
|
|
#2 (permalink) |
|
Member
Join Date: Jul 2007
Posts: 30
|
thanks Nazir, i know about this funtion and i have a javascript book in which i have read about it and some other functions, wel this function is really helpful and we can use it on our application .
|
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Finding work | monkeyhead | Services | 18 | 03-07-2008 05:01 PM |
| Tips & tricks for finding the latest news | Eric | Blogging | 6 | 10-07-2006 01:46 PM |
| Why string are called Immutable data types? | agaba175 | .NET | 0 | 08-01-2006 04:01 PM |