Click to See Complete Forum and Search --> : search function


ashwanichauhan1
January 10th, 2003, 01:17 AM
Dear friends
a very small queation. I am trying to search "."(dot) in a string which is an IP address through search() function in java script but it is not returning me right index. How to do it .

The code is as follows :
var IP = "10.0.1.140"
var index= IP.search(".")

it is always returns 0

Regards ashwani

[Goodz13:Moved from Java Forum]

saddysans
January 10th, 2003, 07:31 AM
First of all javascript is different from java. There is a seperate forum for javascript.
For your question.
use
indexOf() function, se the link for detail
http://wp.netscape.com/eng/mozilla/3.0/handbook/javascript/ref_h-l.htm#360

websmith99
January 10th, 2003, 03:19 PM
saddysans is correct. Use the indexOf() method.

Also, you should not declare a variable with the name "index" as that is a reserved word in JavaScript.