How does one do a simple string search in js?
I want to get a simple true/false answer with if string1 is inside string2 at any position in the string
If string1 is a literal, you can do this:
(string2.search(/string1/)==-1)
Otherwise...
(string2.search(new RegExp(string1))==-1)
Ok, so it is a literal, and if string2 is part of an object, the same applies right?
I should be able to do...
if(ojb.string2.search(/string1/)==-1
That would be if string1 is NOT found right?
What are the //'s for? Are they saying that string1 is literal?
Sysop: | digital man |
---|---|
Location: | Riverside County, California |
Users: | 1,018 |
Nodes: | 17 (1 / 16) |
Uptime: | 05:15:55 |
Calls: | 503,158 |
Calls today: | 12 |
Files: | 225,178 |
D/L today: |
12,258 files (7,743M bytes) |
Messages: | 440,593 |
Posted today: | 6 |