Finding a substring within a string - preCharge Forums
It shows that you are unregistered. Please register with us by clicking Here
preCharge Forums


Nav Green LeftNav Right
preCharge Forums > Website Design & Development > Programming > JavaScript » Finding a substring within a string


Reply
Tcat Right
 
LinkBack Thread Tools Display Modes Tcat Right
Old 07-20-2006   #1 (permalink)
Nazir
Member
 
Join Date: Jul 2006
Age: 48
Posts: 45
Default Finding a substring within a string

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.
Nazir is offline   Reply With Quote


Old 07-21-2007   #2 (permalink)
mr.smith
Member
 
Join Date: Jul 2007
Posts: 30
Default Re: Finding a substring within a string

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 .
mr.smith is offline   Reply With Quote

Old 08-11-2007   #3 (permalink)
Lucid_Seeker
Member
 
Join Date: May 2007
Posts: 90
Default Re: Finding a substring within a string

This stuff is fairly basic Javascript, i could post loads of tutorials on Javascipt but don't because it would take hours of my time, plus i wouldn't get paid
Lucid_Seeker is offline   Reply With Quote

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


footer left
All times are GMT. The time now is 11:40 AM.

DISCLAIMER: preCharge Risk Management is not responsible for any opinions, advice or comments expressed on the preCharge Community Forums.
preCharge® is a registered trademark of preCharge Risk Management | chargeback protection | Merchant Account Blog

Powered by vBulletin
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC6

Remortgages | Loan | Holiday Deals | Credit Card Consolidation | Car Loan

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49