kembali ke pelajaran
Materi ini hanya tersedia dalam bahasa berikut: English, Español, Français, Italiano, 日本語, Русский, 简体中文. Tolong, bantu kami menerjemahkan ke dalam Indonesia.

A match for /d+? d+?/

What’s the match here?

alert( "123 456".match(/\d+? \d+?/g) ); // ?

The result is: 123 4.

First the lazy \d+? tries to take as little digits as it can, but it has to reach the space, so it takes 123.

Then the second \d+? takes only one digit, because that’s enough.