Javascript search

search(regexp)
The search() method is the same as indexOf() except that it takes a
regular expression pattern instead of a substring. It also returns -1 if the
pattern isn’t found.
"hello world".search(/[aeiou]/); // Find the fi rst vowel
1
"hello world".search(/\d/); // Find the fi rst digit
-1
match(regexp)
The match() method returns an array containing all the substrings
matching the regular expression and its subpatterns. Unlike the other
search-and-replace methods, it returns null if the pattern doesn’t match.
Here are some simple examples, but I’ll cover this function more in
Chapter 8:
// Find all the vowels
"hello world".match(/[aeiou]/g);
["e", "o", "o"]
// Find "world" regardless of capitalization
"hElLo WoRlD".match(/world/i);
["WoRlD"]
replace(pattern, replacement)
The replace() method works like match() except that it returns a string
with all instances of pattern replaced by the string replacement.
// Remove all non-numeric characters from a phone number
"(310) 555-9876".replace(/\D/g, "");