我的代碼是:爲什麼JavaScript中的slice()和substr()方法在正則表達式上不起作用?
var st="man myfile=l/p/nm.mp3 yourfile=/o/mj/nnc.mp3 ou p";
var patt=/myfile.[\W|\w]*.mp3\s/;
var s=patt.exec(st);
var s2=s.slice(3,4);
alert(s2);
但切片()給我什麼和SUBSTR()方法給我一個錯誤:
Object doesn't support this method
爲什麼?
'.exec'返回一個對象。你的預期輸出是什麼? – 2013-02-16 15:29:27
@FabrícioMatté耶! '.exec()'方法 – 2013-02-16 15:32:08
我的預期輸出是一個字符串。我如何轉換它? – 2013-02-16 15:37:26