Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

254
Vistas
regex remove short sentences callouts

I want to remove all short sentences (callouts) from a string. See my example below. I want to remove all highlighted text. Maybe text < 25 characters that end with "." enter image description here

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

This regex will target sentenses with a max length of 25.

/(?<=^|\.)\s*.{1,25}?\./gms

Test snippet :

const regex = /(?<=^|\.)\s*.{1,25}?\./gms;
const str = `This is a test.  Keep this longer text that has over 25 characters.  Remove this small text.  `;

const result = str.replace(regex, '');

console.log(result);

Or without a look-behind. For the browsers that stay behind.

/(^|\.)\s*.{1,25}?\./gms

Substitute with first capture group.

const regex = /(^|\.)\s*.{1,25}?\./gms;
const str = `This is a test.  Keep this longer text that has over 25 characters.  
Remove this small text.  `;

const result = str.replace(regex, '$1');

console.log(result);

about 4 years ago · Juan Pablo Isaza Denunciar

0

Maybe this one helps. I didn't consider the '.' char Because I populated this sentence in JS.

const sentence = (() => {
    const sentences = [];
    for (let i = 0; i < 15; i++) {
        const len = Math.floor(Math.random() * (30 - 15 + 1) + 15);
        const sentence = [];
        for (let j = 0; j < len; j++) {
        sentence.push(String.fromCharCode(Math.floor(Math.random() * (122 - 97 + 1) + 97)));
        }
        sentences.push(sentence.join(''));
    }
    return sentences
    })();

    console.log(sentence.length)
    console.log(sentence)
    console.log(sentence.filter(s => s.length > 24))
    console.log(sentence.filter(s => s.length > 24).length)

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda