Encuentra la etiqueta completa
Escriba una expresión regular para encontrar la etiqueta <style...>
. Debe coincidir con la etiqueta completa: puede no tener atributos <style>
o tener varios de ellos <style type="..." id="...">
.
…¡Pero la expresión regular no debería coincidir con <styler>
!
Por ejemplo:
let
regexp =
/
your regexp
/
g
;
alert
(
'<style> <styler> <style test="...">'
.
match
(
regexp)
)
;
// <style>, <style test="...">
El inicio del patrón es obvio: <style
.
…Pero entonces no podemos simplemente escribir <style.*?>
, porque <styler>
coincidiría.
Necesitamos un espacio después <style
y luego, opcionalmente, algo más o el final >
.
En el lenguaje de expresión regular: <style(>|\s.*?>)
.
En acción:
let
regexp =
/
<style(>|\s.*?>)
/
g
;
alert
(
'<style> <styler> <style test="...">'
.
match
(
regexp)
)
;
// <style>, <style test="...">