This regex pattern matches one or more occurrences of the '<br>' tag at the beginning of a string. '^' asserts the position at the start of the string. '<br>' matches the literal '<br>' tag. '+' matches one or more occurrences of the preceding element. The use of parentheses and the '+' quantifier ensures that it captures and matches multiple '<br>' tags at the beginning of the string.
const regex = /^(<br>)+;
const str = '<br><br>Hello, <br>World';
const matches = str.match(regex);
console.log(matches);
Copy