Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用javascript的imgsrc正则表达式_Javascript - Fatal编程技术网

使用javascript的imgsrc正则表达式

使用javascript的imgsrc正则表达式,javascript,Javascript,我要为该字符串模式重新设置: src="http://www.prphotos.com/f/1335/CSM-001335/Robert-Pattinson,-Reese-Witherspoon-Water-for-Elephants-New-York-City-Premiere---Arrivals.jpg" border="0" 我正在使用: <img.[\w+\s+\d+\W]*/> 我还需要为不同的语言(如javascript、PHP等)编写不同的RE吗?]*/>

我要为该字符串模式重新设置:

src="http://www.prphotos.com/f/1335/CSM-001335/Robert-Pattinson,-Reese-Witherspoon-Water-for-Elephants-New-York-City-Premiere---Arrivals.jpg"  border="0"
我正在使用:

<img.[\w+\s+\d+\W]*/>

我还需要为不同的语言(如javascript、PHP等)编写不同的RE吗?

]*/>
<img [^>]*src=".*?[^\]"[^>]*/>

您可能需要编写
\
,因为我将使用真正的dom解析器。但是,通常的方法是使用HTML解析器。您的用例是什么?你在搜索什么样的数据?问题是不明确的:你是否在尝试匹配任何图像标记,只匹配带有src=“…”和border=“…”,只匹配来自prpphotos.com的图像标记,只匹配来自此特定站点的特定类型的图像标记,等等?感谢它发挥了很多作用,现在我只想提取src,或者它可以在数组中返回,这样我就可以使用src了。如果有一个内部带有“s”的url,那么该修改将导致解析失败