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

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

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

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

    Find all numbers

    Write a regexp that looks for all decimal numbers including integer ones, with the floating point and negative ones.

    An example of use:

    let regexp = /your regexp/g;
    
    let str = "-1.5 0 2 -123.4.";
    
    alert( str.match(regexp) ); // -1.5, 0, 2, -123.4

    A positive number with an optional decimal part is: \d+(\.\d+)?.

    Let’s add the optional - in the beginning:

    let regexp = /-?\d+(\.\d+)?/g;
    
    let str = "-1.5 0 2 -123.4.";
    
    alert( str.match(regexp) );   // -1.5, 0, 2, -123.4
    • © 2007—2025  Ilya Kantor
    • دربارهٔ پروژه
    • تماس با ما