suchen

Heim  >  Fragen und Antworten  >  Hauptteil

javascript - Über match()

alert('rgb(255)'.match(/rgb((d+))/));

Suche nach Übereinstimmungen. Sie sind sich nicht sicher, warum es zurückgegeben wurde ["rgb(255)", "255"]?

Warum nicht einfach wiederkommen"rgb(255)"

PHP中文网PHP中文网2858 Tage vor536

Antworte allen(2)Ich werde antworten

  • 天蓬老师

    天蓬老师2017-05-19 10:20:34

    因为你用了捕获,就是那个括号。

    console.log('rgb(255)'.match(/rgb\((\d+)\)/));

    不用捕获就对了

    console.log('rgb(255)'.match(/rgb\(\d+\)/));

    Antwort
    0
  • 大家讲道理

    大家讲道理2017-05-19 10:20:34

    这种问题请直接翻文档:String.prototype.match()

    Antwort
    0
  • StornierenAntwort