Context
I'm new to regex (still practicing) and I'm trying to extract script src or link href values from tags (for education purposes).
Given following html
<!-- hello -->
<script src="1.js"></script>
<script src="2.js"></script>
<link rel="stylesheet" href="3.css"/>
<!-- world -->
I'd want to get
array of: 1.js, 2.js and 3.css
I've tried
This is the regex I've did so far, but meh.
/(?:<!-- hello -->\s*?)([\s\S]*?)(?:\s?<!-- world -->)/gmi
Of course, I have to replace [\s\S]*? with something better but I've tried a lot of combinations and none of them worked.
Regards.
Update
Only scripts between <!-- xxx --><!-- xxx--> tags should be matched.
Following should not match:
<!-- foo-->
<script src="4.js"></script>
<script src="5.js"></script>
<link rel="stylesheet" href="6.css"/>
<!-- bar-->
/(?:src|href)="([^"]*)"/gand grab Group 1 values.