📝 Edit page
➕ Add page
Methods
Related
- Contains cheatsheet
- [Regex cheatsheet][]
[Regex cheatsheet] /dev-cheatsheets/cheatsheets/javascript/general/strings/regex.html
indexOf method
- indexOf in MDN docs
STRING.indexOf(SEARCH_VALUE)
STRING.indexOf(SEARCH_VALUE, FROM_INDEX)
search method
- search in MDN docs
A search for a match between a regular expression and a string object.
const paragraph = 'The quick brown fox jumps over the lazy dog. If the dog barked, was it really lazy?';
// Any character that is not a word character or whitespace
const regex = /[^\w\s]/g;
paragraph.search(regex)
// 43
paragraph[paragraph.search(regex)]
// "."
match method
- match in MDN docs
Retrieve the result of matching a string against a regular expression.