Find the full tag
Write a regexp to find the tag <style...>
. It should match the full tag: it may have no attributes <style>
or have several of them <style type="..." id="...">
.
…But the regexp should not match <styler>
!
For instance:
let regexp = /your regexp/g;
alert( '<style> <styler> <style test="...">'.match(regexp) ); // <style>, <style test="...">
The pattern start is obvious: <style
.
…But then we can’t simply write <style.*?>
, because <styler>
would match it.
We need either a space after <style
and then optionally something else or the ending >
.
In the regexp language: <style(>|\s.*?>)
.
In action:
let regexp = /<style(>|\s.*?>)/g;
alert( '<style> <styler> <style test="...">'.match(regexp) ); // <style>, <style test="...">