javascript - 正则表达式字符串 URL

标签 javascript regex

示例

 1. http://ad.ly/123411/http://blabalba.com/adaf
 2. http://ad.ly/142145/http://blabal.com/adf34

how to replace front String http://ad.ly/1246721/ use js regex
into http://blabalbal.com/adaf

得到这个http://blabalbal.com/adaf

最佳答案

所需的正则表达式为http:\/\/adf_.ly\/\d+\/(.+)

var str = 'http://adf_.ly/1246721/http://prefiles.com/files';
var re = /http:\/\/adf_.ly\/\d+\/(.+)/;
var newstr = re.exec(str)[1];

关于javascript - 正则表达式字符串 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20344451/

相关文章:

javascript - 使用 forEach 循环遍历 Array(n),未定义值的数组

javascript - 获取iframe中的元素

c# - 如何保留 Regex.Split 的分隔符?

python - 使用正则表达式重新排序字符串

regex - 使用 golang 解析 Perl 正则表达式

javascript - 如何循环浏览 highcharts 主题

javascript - 针对爬虫和机器人的 HTML 5 存储

javascript - 当 ob1.prototype 未定义时,Object.create() 如何从 ob1.prototype 创建 obj2.__proto__ ?

c# - 如何捕获带缩进的字符串组?

python - 查找通过从给定字符串中删除字母而创建的单词