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

113
Vistas
I need a JavaScript RegEx to capture all words after a lookbehind

I'm really trying to understand RegEx and I feel like this issue should be easy and straightforward, but for some reason I'm really struggling to get exactly what I need. I've looked through at least 20 articles here and none of them are getting me there.

What I need is to capture all words after a lookbehind so I can count them. Here's what I've got so far:

RegEx: /(?<=\> )(\w*)/gi
String: "Mon Jan 11 11:00 <ralph> Hello all!!"

Capture all words after "> ", so in the above I only want the capture group to individually capture "Hello" and "all", so I can count the group and get the number words after the username, "<ralph>" in this example.

The above RegEx is just what I'm currently working with and it of course is only capturing the first word. I've also tried putting * and + after the capture group, but that nullifies the capture group for some reason.

I've also tried (?<=\> )((\w*)(?:\W+))*, and while this does match everything after the lookbehind, it only captures "all!!" and "all" in the 2 different captures. I'm not sure why "!!" is returning in any capture as I have it to match only with (?:).

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

0

For example

const str = "Mon Jan 11 11:00 <ralph> Hello all. How are you?";

console.log( str.match(/(?<=\> (?:\w+\W+)*)\w+/g) );

I'm not sure why "!!" is returning in any capture as I have it to match only with (?:).

Yes, but it is also captured by the first capture group. For example, if "x" is matched by ((?:x)), then the first capture group will contain "x" even though it is also inside the second group which is non-capturing.

about 4 years ago · Juan Pablo Isaza Denunciar

0

(?<=\> )(.+) works fine for me it captures Hello all!! from Mon Jan 11 11:00 <ralph> Hello all!! Is it what you need?

about 4 years ago · Juan Pablo Isaza Denunciar

0

Is there a regular pattern after the > or it's random?

Anyway, this (?<=\> )(.*) matches your example.

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