UNPKG

comment-regex

Version:

Regular expression for matching JavaScript comments

12 lines (9 loc) 274 B
export function lineCommentRegex() { return /(?:^|\s)\/\/(.+?)$/gms; } export function blockCommentRegex() { return /\/\*(.*?)\*\//gms; } export function commentRegex() { return new RegExp(`(?:${lineCommentRegex().source})|(?:${blockCommentRegex().source})`, 'gms'); }