Skip to content

Instantly share code, notes, and snippets.

@mmollick
Last active September 7, 2016 15:12
Show Gist options
  • Select an option

  • Save mmollick/7f028d9039a04fe116b4afbd9a10cf59 to your computer and use it in GitHub Desktop.

Select an option

Save mmollick/7f028d9039a04fe116b4afbd9a10cf59 to your computer and use it in GitHub Desktop.
Extract javascript object components

Heres an example of what a match will look like

/**
     * Request timeout in milliseconds
     * After this threshold is reached the result is assumed unknown. This is likely
     * a trouble host that will take extra time to resolve.
     */
    timeout: {
        default: 30000,
        type: 'integer'
    }
/**
* Read the contents of an javascript file containing an array as a string; ie: fs.readFileSync(...)
* This regex will match the docblock and the object item following it
*/
regex = /(\/\*\*[\s]+((.(?!.*\*\/))+\s)+[\s]+\*\/[\s]+[\w\d]+\:\s\{(\s(.(?!.*(\}\,|\}\s\})))+)+(\s)+\}\,?)/g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment