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

332
Views
Regex (JS) read data between two symbols

My changelog.md data looks like below.

## 11.2.3
* xxx
* xxxx

## 11.2.2
* ttt
* ttt

I need a regex that can return only the first versions list ie.

* xxx
* xxxx

I tried multiple solutions but, didn't reach the final result.

I tried matching, and replacing it, didn't work.

const changelog = `
## Hello World
* This is a bold text
* This is a bold text

## Hello World
* This is a bold text

## Hello World
* This is a bold text
`;

const final = changelog.match( /([^(##)])(.*)[^(##)]/g );
console.log(final);

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You don't need to put ^## inside []. Square brackets are for making character sets, () is for grouping. There's no need to group it if you're not interested in that part.

Use the m modifier to make ^ match the beginning of a line instead of the the beginning of the string. Then .*\n will match the rest of that line. [^#]* will match everything after that until the next #.

const changelog = `
## Hello World
* This is a bold text
* This is a bold text

## Hello World
* This is a bold text

## Hello World
* This is a bold text
`;

const final = changelog.match(/^##.*\n([^#]*)/m);
console.log(final[1]);

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!