Skip to content

Instantly share code, notes, and snippets.

@MartinSvarrer
Last active August 29, 2015 14:16
Show Gist options
  • Save MartinSvarrer/ca7bcbc39577a842a3ce to your computer and use it in GitHub Desktop.
Save MartinSvarrer/ca7bcbc39577a842a3ce to your computer and use it in GitHub Desktop.
Requirejs define function regex
// Regex breakdown:
// Group: define([
// Group: dependencies
// Group: ], function (
// Group: arguments
// Group: ) {
var defineFuncBeginning = /(define\s*?\(\s*?\[)([\S|\s]*?)(\]\s*,\s*function\s*\()([\s|\S]*?)(\)\s*?{)/gmi,
defineFuncBeginningResult = defineFuncBeginning.exec(file);
console.log(defineFuncBeginningResult[2]); // output: string with all dependencies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment