I am looking for a regex that can match any line of code that contains a single reference to a core module)
Something like this:
const coreModuleMatches = /'^[var|const]{0,1}[a-z\$\_]{1,}=require([\'|"][assert|fs|path][\'|"])[;|,]{0,1}$/;
This should match all of these lines
var pth = require("path");
const asrt = require('assert'),
fs = require('fs'),
cp = require('child_process');
The problem is I can't get the simple regex to work, so my more complex regex currently has no hope.
I am stripping out all whitespace except newline characters before matching the code with regular expressions, and then splitting by newline so that I can go line by line through the code. Any ideas welcome.