Skip to content

Instantly share code, notes, and snippets.

@spamshaker
Created August 11, 2023 04:11
Show Gist options
  • Save spamshaker/670654f81eff9956ff723889ee9da1fb to your computer and use it in GitHub Desktop.
Save spamshaker/670654f81eff9956ff723889ee9da1fb to your computer and use it in GitHub Desktop.
match-jsdoc-comment.js
`/**
* This is a comment
*/
class MyClass {
/**
* This is a comment
*/
function doSmth(){
const thing = '';
return thing + 'done';
}
/**
* This is a comment
*/
function toString(){
return 'MyClass'
}
}
`.match(/(?:\/\/.*$)|(?:\/\*[\s\S]*?\*\/)/g)
// out: [ "/**\n * This is a comment\n */", "/**\n \t * This is a comment\n */", "/**\n \t * This is a comment\n */"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment