I want to get elements with content having class name beginning with specific word using regex without using querySelectorAll. For example :
I have two elements
<h1 class="school">Primary</h1>
<h1 class="school project">Secondary</h1>
function match(className) {
regex = new RegExp(/<([^\s]+).*?class="school".*?>(.+?)<\/\1>/gi);
matches = data.match(regex);
return matches
}
this regex only match with the first and not with second element having name "school project"
How to customize this regular expression that it will match all elements having class name beginning with specific name and how to concatenate the class name dynamically based on paramter className of match function in regex instead of hard coding it in regex