请帮助我:
我在字符串中有一批链接,比如
http://hw-img.website.com/photo/01252018.jpg
http://hw-img.website.com/photo/21212015.jpg
http://hw-img.website.com/photo/11162012.jpg
我需要找到所有:
hw-img*com/
find start 'hw-img' than any char before finding end 'com/'
并替换所有与" newsite.com/hw-img /"得到
http://website.com/hw-img/photo/01252018.jpg
http://website.com/hw-img/photo/21212015.jpg
http://website.com/hw-img/photo/11162012.jpg
我需要写什么正则表达式来执行此操作?谢谢!
答案 0 :(得分:0)
如果您的input
是单个字符串(带有嵌入的换行符),那么此代码段应该会产生所需的结果:
input.replace(/hw-img.*?com\//g, 'newsite.com/hw-img/')