نريد أن نتيح هذا المشروع المفتوح المصدر إلى كل الناس حول العالم. من فضلك ساعدنا على ترجمة محتوى هذه السلسله للغة التى تعرفها.
الرجوع الي الدرس
هذة المادة العلميه متاحه فقط باللغات الأتيه: English, Español, Français, Italiano, 日本語, Русский, Українська, Oʻzbek, 简体中文. من فضلك, ساعدنا قم بالترجمه إلى عربي.

Java[^script]

We have a regexp /Java[^script]/.

Does it match anything in the string Java? In the string JavaScript?

Answers: no, yes.

  • In the script Java it doesn’t match anything, because [^script] means “any character except given ones”. So the regexp looks for "Java" followed by one such symbol, but there’s a string end, no symbols after it.

    alert( "Java".match(/Java[^script]/) ); // null
  • Yes, because the [^script] part matches the character "S". It’s not one of script. As the regexp is case-sensitive (no i flag), it treats "S" as a different character from "s".

    alert( "JavaScript".match(/Java[^script]/) ); // "JavaS"