JavaScript: String.prototype.search

By Xah Lee. Date: . Last updated: .
str.search(regex_or_str)
Return the index of first char of matched string. If no match, returns -1.
If argument is string, it is converted to regex by RegExp

[see Regex Functions]

console.log("abc123xyz".search(/\d/)); // 3
console.log("abc123xyz".search(/what/)); // -1
JS in Depth
XAH  BUY NOW

JS in Depth

JS Obj Ref

DOM


JS Obj Ref

String

prototype