【发布时间】:2021-07-02 18:57:08
【问题描述】:
我在数据中有这个 字符串 元素:
"<html>
<head>
<meta http-equiv="pr" content="no-cache">
<title>Redirection to 20331...</title>
</head>
<body>
<script> language="javascript">
location = 'https://cloud.analytics.google.com:92/force/ForceRedirect/Redirect.do?id=20331';
</script>
</body>
</html>"
我需要提取此字符串中的 URL。
当前实现:
data.split(' ')[6].split("'")[0];
这个 workaround 将链接返回给我并且工作正常,但是因为我基本上是硬编码 URL 的位置,所以我需要一种方法来处理这个问题。感谢任何反馈!
【问题讨论】:
标签: javascript regex string url ecmascript-6