Text Processingflags: g
C-Style Block Comment
Match C-style /* ... */ block comments across multiple lines.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
\/\*[\s\S]*?\*\/ (flags: g)Raw source: \/\*[\s\S]*?\*\/
How it works
\/\* matches the literal `/*`. [\s\S]*? lazily matches any characters including newlines (the [\s\S] idiom avoids needing a dotAll/s flag). \*\/ matches the closing `*/`. Lazy matching ensures adjacent comment blocks aren't merged into one giant match.
Examples
Input
/* one */ var x = 1; /* two\nlines */ y = 2;Matches
/* one *//* two\nlines */
Input
/** JSDoc here */Matches
/** JSDoc here */
Input
// not a block commentNo match
—Common use cases
- •Stripping comments from source for minification
- •Extracting JSDoc / Doxygen blocks for documentation
- •Linting commented-out code
- •Translating comment styles between languages
Related patterns
Single-Line Comment (// or #)
Text ProcessingMatch single-line comments using either the `//` (C-family) or `#` (shell, Python, Ruby, YAML) marker.
Terraform Resource Block Header
Text ProcessingMatch the opening line of a Terraform `resource "type" "name" {` block, capturing the resource type and local name.
Whitespace-Only Line
Text ProcessingMatches lines containing only whitespace (or empty lines).
Emoji (Unicode)
Text ProcessingMatch emoji characters across the main Unicode emoji ranges — requires the Unicode flag in JavaScript.