I have this Python code, I want to map the array of regex strings, to compiled regexes, and I need to create a function that checks to see if a certain line of texts matches all the given regular expressions. But I suck at Python and only know JS and Java.
#sys.argv[2] is a JSON stringified array
regexes = json.loads(sys.argv[2]);
#need to call this for each regex in regexes
pattern = re.compile(regex)
def matchesAll(line):
return True if all line of text matches all regular expressions
In JS, what I want looks like:
// process.argv[2] is a JSON stringified array
var regexes = JSON.parse(process.argv[2])
.map(v => new RegExp(v))
function matchesAll(line){
return regexes.every(r => r.test(line));
}
Can somehow help me translate? I was reading about how to do mapping of arrays with Python and I was like huh?