Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

106
Views
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 answers
Answer question

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 Report

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 Report

0

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

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

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!