• ARعربي
  • ENEnglish
  • ESEspañol
  • FAفارسی
  • FRFrançais
  • IDIndonesia
  • ITItaliano
  • JA日本語
  • KO한국어
  • RUРусский
  • TRTürkçe
  • UKУкраїнська
  • ZH简体中文

ما قصد داریم این پروژهٔ متن‌باز را در دسترس همهٔ مردم در سرتاسر دنیا قرار دهیم.

به ترجمهٔ محتوای این آموزش به زبان خودتان کمک کنید/a>.

    نقشه آموزش
    اشتراک گذاری
    • آموزش
    • عبارات باقاعده (Regular Expression)
    • Alternation (OR) |
    بازگشت به درس
    این محتوا تنها در این زبان‌ها موجود است: عربي, English, Español, Français, Italiano, 日本語, Русский, Українська, 简体中文. لطفاً به ما

    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="...">
    • © 2007—2025  Ilya Kantor
    • دربارهٔ پروژه
    • تماس با ما