JS: String.prototype.search
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
// find digit console.log("a 99 b".search(/\d/) === 2); // true // using string as arg console.log("a 99 b".search("\\d") === 2); // true // not found console.log("a 99 b".search("ttt") === -1); // true
JavaScript. Regular Expression
- JS: RegExp Tutorial
- JS: Regex Functions
- JS: Create Regex Object
- JS: RegExp Syntax
- JS: RegExp Flag
- JS: Regex Replace String Dollar Sign
- JS: Regex Replace Function Args
- JS: RegExp (class)
- JS: RegExp Constructor
- JS: RegExp.prototype
- JS: String.prototype.search
- JS: String.prototype.match
- JS: String.prototype.matchAll
- JS: String.prototype.replace
- JS: String.prototype.replaceAll
- JS: RegExp.prototype.test
- JS: RegExp.prototype.exec
JS String.prototype
- JS: String.prototype.constructor
- JS: String.prototype.at
- JS: String.fromCharCode
- JS: String.prototype.concat
- JS: String.prototype.repeat
- JS: String.prototype.trim
- JS: String.prototype.trimStart
- JS: String.prototype.trimEnd
- JS: String.prototype.padStart
- JS: String.prototype.padEnd
- JS: String.prototype.slice
- JS: String.prototype.substring
- JS: String.prototype.substr
- JS: String.prototype.indexOf
- JS: String.prototype.lastIndexOf
- JS: String.prototype.includes
- JS: String.prototype.startsWith
- JS: String.prototype.endsWith
- JS: String.prototype.search
- JS: String.prototype.match
- JS: String.prototype.matchAll
- JS: String.prototype.replace
- JS: String.prototype.split
- JS: String.prototype.toLowerCase
- JS: String.prototype.charAt
- JS: String.prototype.charCodeAt
- JS: String.prototype.codePointAt