正則獲取字符串中圖片路徑

var reg = /<img[^>]*src[=\'\"\s]+([^\"\']*)[\"\']?[^>]*>/gi; 
var str = '<p><img alt=\"\" src=\"/uploads/ckeditor/pictures/7/content_1234594100532399625.jpg\" style=\"width: 700px; height: 560px;\" />132<img alt=\"\" src=\"/uploads/ckeditor/pictures/8/content_1901904_140154707195_2.jpg\" style=\"width: 800px; height: 531px;\" /></p>\r\n';
while (reg.exec(str)) 
{
    console.log(RegExp.$1); 
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章