const regex = new RegExp('(\\d{1,2}(\\°|er|do|to|mo|vo|no|ro|ra|da|ta|ma|va|na|)\\s?(piso|planta)|planta baja|primer piso|segundo piso|tercer piso|cuarto piso|quinto piso|sexto piso|s[ée]ptimo piso|[úu]ltim[oa] (piso|planta))', 'gmi')
const str = `Hermoso departamento 3 ambientes al frente , muy luminoso con vista panoramica . Cocina integrada , baño completo , balcon aterrazado vidriado con cerramientos 3e. Agua caliente central , Abl: \$ 276.-A 1 cuadra de Av. Rivadavia al 2600 y a 2 de Av. Pueyrredon , Subte A , Trenes , Ramales de Colectivos. A 2 cuadras del Shopping Spinetto. A pocas cuadras del Congreso de la Nación. .Información Adicional: Monto de las expensas: 1900Gas naturalGas naturalCaracterísticas y servicios del edificio: Agua corrienteElectricidadGas natural
ID: 221464 ultima planta`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions