Tengo una variable que contiene algo de texto, algo de HTML, básicamente puede ser una cadena. Necesito buscar en la variable una cadena específica para procesar esa variable de manera diferente si está contenida. Aquí hay un fragmento de lo que estoy tratando de hacer, obviamente, no funciona :)jQuery ¿Buscar texto en una variable?
$.each(data.results,
function(i, results) {
var text = this.text
var pattern = new RegExp("^[SEARCHTERM]$");
if(pattern.test(text))
alert(text); //was hoping this would alert the SEARCHTERM if found...
¿Qué dice cuando haces una 'alerta (this.text)'? – ajreal