JavaScript - String - Match Function
var text = "The rain in SPAIN stays mainly in the plain";
alert(text.match("ain").join(" "));
var text = "The rain in SPAIN stays mainly in the plain";
alert(text.match(/ain/).join(" "));
var text = "The rain in SPAIN stays mainly in the plain";
alert(text.match(/ain/g).join(" "));
var text = "The rain in SPAIN stays mainly in the plain";
alert(text.match(/ain/i).join(" "));
var text = "The rain in SPAIN stays mainly in the plain";
alert(text.match(/ain/gi).join(" "));
var text = "The rain in SPAIN stays mainly in the plain";
alert(text.match(/ain$/).join(" "));
var text = "Hola mundo";
alert(text.match(/(H)(o)(l)(a) (m)(u)(n)(d)(o)/).join(" "));
var text = "Hola mundo";
str = text.match(/(H)(o)(l)(a) (m)(u)(n)(d)(o)/).groups;
alert(JSON.stringify(str));
////////////////////////////////////////////////////////////////
//Solo letras mayúsculas
var text = "The rain in SPAIN stays mainly in the plain";
alert(text.match(/[A-Z]/g).join(" "));
//Solo letras minúsculas
var text = "The rain in SPAIN stays mainly in the plain";
alert(text.match(/[a-z]/g).join(" "));
//Solo vocales minúsculas
var text = "The rain in SPAIN stays mainly in the plain";
alert(text.match(/[aeiou]/gi).join(" "));
//Solo vocales mayúsculas
var text = "The rain in SPAIN stays mainly in the plain";
alert(text.match(/[AEIOU]/gi).join(" "));
//Solo vocales minúsculas y mayúsculas
var text = "The rain in SPAIN stays mainly in the plain";
alert(text.match(/[aeiouAEIOU]/g).join(" "));
//Solo consonantes minúsculas
var text = "The rain in SPAIN stays mainly in the plain";
alert(text.match(/[bcdfghjklmnpqrstvwxyz]/gi).join(" "));
//Solo consonantes mayúsculas
var text = "The rain in SPAIN stays mainly in the plain";
alert(text.match(/[BCDFGHJKLMNPQRSTVWXYZ]/gi).join(" "));
//Solo consonantes minúsculas y mayúsculas
var text = "The rain in SPAIN stays mainly in the plain";
alert(text.match(/[bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ]/g).join(" "));
//////////////////////////////////////////////////////////////////
//Solo letras dígitos
var text = "The rain 23 in SPAIN stays mainly in the plain";
alert(text.match(/\d+/g).join(" "));
//Solo caracteres especiales
var text = "Hola123!@#";
alert(text.match(/[^a-zA-Z0-9]/g).join(" "));