Javascript : Reg Exp
Regular Expressions
Match
Searches a string for a match against a regular expression and returns the matches as an Array. I'm not sure why anyone would use this if it just returns an array with identical values.
var str = "The rain in SPAIN stays mainly in the plain";
var res = str.match(/ain/g);
//returns: Array [ "ain", "ain", "ain" ]
Search
Its just like indexOf except it allows regular expressions. Returns -1 if no match is found.
var str = "I like pretty girls";
var n = str.search("pretty");
//returns 7