asdasdsad <video controls="controls" controlslist="nodownload" width="800" height="667" src="/uploadfile/video/20220708/20220708093256358001.mp4"> <object classid="clsid:6bf52a52-394a-11d3-b153-00c04f79faa6" width="800" height="667"> <param name="url" value="/uploadfile/video/20220708/20220708093256358001.mp4"> <param name="autostart" value=""> <param name="uimode" value="full"> <embed type="application/x-mplayer2" src="/uploadfile/video/20220708/20220708093256358001.mp4" width="800" height="667" autostart="" uimode="full" pluginspage="http://microsoft.com/windows/mediaplayer/en/download/"> </object> </video> asdasdasd adasdasd <html> 这段字符串正则提取video内容
时间: 2023-07-02 22:22:27 浏览: 186
可以使用正则表达式来提取这段字符串中的视频路径。以下是一个示例正则表达式:`src="(.*?\.mp4)"`,其中 `.*?` 表示匹配任意字符(非贪婪模式),`\.mp4` 表示匹配 .mp4 后缀。可以使用 Python 中的 re 模块来实现正则表达式匹配。以下是一个示例代码:
```python
import re
string = 'asdasdsad <video controls="controls" controlslist="nodownload" width="800" height="667" src="/uploadfile/video/20220708/20220708093256358001.mp4"> <object classid="clsid:6bf52a52-394a-11d3-b153-00c04f79faa6" width="800" height="667"> <param name="url" value="/uploadfile/video/20220708/20220708093256358001.mp4"> <param name="autostart" value=""> <param name="uimode" value="full"> <embed type="application/x-mplayer2" src="/uploadfile/video/20220708/20220708093256358001.mp4" width="800" height="667" autostart="" uimode="full" pluginspage="http://microsoft.com/windows/mediaplayer/en/download/"> </object> </video> asdasdasd adasdasd <html>'
pattern = r'src="(.*?\.mp4)"'
results = re.findall(pattern, string)
print(results) # 输出 ['/uploadfile/video/20220708/20220708093256358001.mp4']
```
注意,这个正则表达式只适用于上述字符串中的视频路径提取,如果你需要提取其他格式的视频路径可能需要根据具体情况进行修改。
阅读全文