So I'm just curious if there was a way to chain regexp. Just looking to optimize my code a little. I want to find an expression, then find another one from the results.
The Working Code:
match = $('body').html().match(/(\[~\{ .*? \}~\])/g);
console.log(match[0]);
findText = match[0].match(/\w+/);
console.log(findText);
What I've tried:
match = $('body').html().match(/(\[~\{ .*? \}~\])(\w+)/g);
console.log(match[0]);
produced an error
match = $('body').html().match(/(\[~\{ .*? \}~\])|(\w+)/g);
console.log(match[0]);
Found Expression 1 and then Found Expression 2 outside of expression 1.
My HTML:
[~{ header }~]
<p>This is the home page</p>
[~{ footer }~]