این محتوا تنها در این زبانها موجود است: عربي, English, Español, Français, Italiano, 日本語, Русский, Українська, Oʻzbek, 简体中文. لطفاً به ما
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: