Keep-a-Changelog Entry Header
Match Keep-a-Changelog style version headers like `## [1.2.3] - 2024-01-15` or `## 2.0.0`.
Try it in RegexPro →Available in
JavaScript / ECMAScript code
const re = new RegExp("^##\\s+\\[?([\\w.\\-]+)\\]?(?:\\s*-\\s*(\\d{4}-\\d{2}-\\d{2}))?", "gm");
const input = "## [1.2.3] - 2024-01-15\\n## [Unreleased]";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).
Python (re) code
import re
pattern = re.compile(r"^##\s+\[?([\w.\-]+)\]?(?:\s*-\s*(\d{4}-\d{2}-\d{2}))?", re.MULTILINE)
input_text = "## [1.2.3] - 2024-01-15\n## [Unreleased]"
for m in pattern.finditer(input_text):
print(m.group(0))Stdlib `re` module — no third-party dependency. Works on Python 3.6+.
Go (RE2) code
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`(?m)^##\s+\[?([\w.\-]+)\]?(?:\s*-\s*(\d{4}-\d{2}-\d{2}))?`)
input := `## [1.2.3] - 2024-01-15\n## [Unreleased]`
for _, match := range re.FindAllString(input, -1) {
fmt.Println(match)
}
}Uses `regexp.MustCompile` (panics on bad patterns at startup) and `FindAllString` for all matches.
Pattern
^##\s+\[?([\w.\-]+)\]?(?:\s*-\s*(\d{4}-\d{2}-\d{2}))? (flags: gm)Raw source: ^##\s+\[?([\w.\-]+)\]?(?:\s*-\s*(\d{4}-\d{2}-\d{2}))?
How it works
Examples
Input
## [1.2.3] - 2024-01-15\n## [Unreleased]Matches
## [1.2.3] - 2024-01-15## [Unreleased]
Input
## 2.0.0 - 2025-12-25Matches
## 2.0.0 - 2025-12-25
Input
# TitleNo match
—Common use cases
- •Automated changelog parsing in release tooling
- •Versioned doc generation
- •Migrating between changelog formats
- •CI checks for missing/empty release sections
Related patterns
GraphQL Operation Header
Text ProcessingMatch GraphQL operation headers — `query`, `mutation`, or `subscription` — capturing the operation name.
Terraform Resource Block Header
Text ProcessingMatch the opening line of a Terraform `resource "type" "name" {` block, capturing the resource type and local name.
C-Style Block Comment
Text ProcessingMatch C-style /* ... */ block comments across multiple lines.
HCL / Terraform Variable Reference
Text ProcessingMatch Terraform / HCL references like `var.name`, `local.foo`, `module.x.output`, or `data.aws_ami.ubuntu.id`.