Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help me with search function in javascript

Status
Not open for further replies.

tadevosyanaram

Programmer
Jul 17, 2003
1
0
0
AM
When I'm writing a script

var j="abcdefg";
j.search( ")" );

it gives me error. How can i search within a string a simbol "(" or ")"
thank you
 
Use indexOf instead of search.

var str="abcdef(gh";
alert(str.indexOf("("));

This works fine..
 
correction:
its lastIndexOf("(") and not indexOf(java)

Known is handfull, Unknown is worldfull
 
vbkris,

javascript has both the indexOf() and lastIndexOf() functions...they are comparable to vbscript's InStr and InStrRev functions respectively.


=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
ah....

thanks for pointing it out to me...

Known is handfull, Unknown is worldfull
 
Hi,

Here is a way to find your brackets by using a regular expression in combination with the search() function in javascript

for the openeing bracket use
j.search(/\(/g);

for the closing bracket
j.search(/\)/g);


ciau
Faadiel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top