[Javascript] Search for a substring in a string
Andrew Gibson
andyg at ihug.co.nz
Sun Sep 14 18:17:39 CDT 2003
Try this:
var mystr = "these dogs are dirty"
var found=mystr.indexOf("dogs")
// found would be an integer where the str is... -1 means not found
Andrew Gibson
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
Subject: [Javascript] Search for a substring in a string
Forgive me if my questions are too basic.
I want to check for the existence of a substring within a string, more or
less like
the hypothetical syntax below :
var mystr = "these dogs are dirty"
if (mystr contains "dogs") {do stuff }
More information about the Javascript
mailing list