你好 friend ,我想创建一个函数,在搜索之前从输入链接中删除特定的单词组:
我得到了这个编码:
jquery:
<script type="text/javascript">
function GetIdinfo() {
var q = document.getElementById("graph").value;
window.open("http://graph.facebook.com/" + q,"", "width=500px, height=300px");
}
</script>
HTML:
<form action="index.php" method="get">
<input id="graph" type="text" name="q" size="20" placeholder="Guru.of.Fun or 100XXXX"/></td>
<input type="button" name="graph" value="Get Facebook Data" class="submit" onclick="GetIdinfo()" />
现在我想获得一些帮助来删除https://graph.facebook.com/
并且仅读取反斜杠/
之后的文本:
100008622 from full link https://www.facebook.com/100008622
- 如果任何用户在搜索文本区域中输入..
最佳答案
您可以使用正则表达式
var regex = /\d+/g;
var string = "https://www.facebook.com/100008622";//window.location.href you can use directly this;
var matches = string.match(regex);
alert(matches);
关于javascript - 使用 jquery 从链接中删除不需要的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30257755/