Extract image src from a string

前端 未结 5 520
遇见更好的自我
遇见更好的自我 2020-11-30 06:02

I\'m trying to match all the images elements as strings,

This is my regex:

html.match(/]+src=\"http([^\">]+)/g);

Th

5条回答
  •  渐次进展
    2020-11-30 06:33

    You can access the src value using groups

                                                       |->captured in group 1
                                       ----------------------------------                
    var yourRegex=/]+src\s*=\s*"(http://static2.ccn.com/ccs[^">]+)/g;
    var match = yourRegex.exec(yourString);
    alert(match[1]);//src value
    

提交回复
热议问题