Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从string-jQuery或Javascript获取url_Javascript_Jquery_Html - Fatal编程技术网

如何从string-jQuery或Javascript获取url

如何从string-jQuery或Javascript获取url,javascript,jquery,html,Javascript,Jquery,Html,我有这样的url: http://192.168.6.1/Images/Work3ererg.png http://192.168.6.1/Images/WorwefewfewfefewfwekThumb.png http://192.168.6.1/Images/ewfefewfewfewf23243.png http://192.168.6.1/Images/freferfer455ggg.png http://192.168.6.1/Images/regrgrger54654654.png

我有这样的url:

http://192.168.6.1/Images/Work3ererg.png
http://192.168.6.1/Images/WorwefewfewfefewfwekThumb.png
http://192.168.6.1/Images/ewfefewfewfewf23243.png
http://192.168.6.1/Images/freferfer455ggg.png
http://192.168.6.1/Images/regrgrger54654654.png
我想知道
http://192.168.6.1
从这些url…如何使用jquery或javascript实现这一点

我想做什么:

i got this string from my JavaScript :  http://192.168.6.1/Images/Work3ererg.png
使用此脚本字符串:

我想把
**https://192.168.6.1/**
而不是
**http://localhost:37774**
包括http

$("#" + id).css("background", "rgba(0, 0, 0, 0) url(http://localhost:37774/Images/PBexVerticalLine1.png) no-repeat scroll 0% 0% / auto padding-box border-box")
谢谢

url.indexOf('/',7)
表示在
http://

然后使用
substr
从开始到
http://

url.indexOf('/',7)
表示在
http://

然后使用
substr
从开始到
http://

url.indexOf('/',7)
表示在
http://

然后使用
substr
从开始到
http://

url.indexOf('/',7)
表示在
http://

然后使用
substr
从开始到
http://

之后的第一个
/
获取字符串。如果浏览器支持(IE 10及更高版本和最新浏览器),则可以使用

您只需这样做:

var test = new URL('http://192.168.6.1/Images/regrgrger54654654.png')
console.log(test.origin)
如果要使用正则表达式,则在这种情况下可以:

var url = 'http://192.168.6.1/Images/regrgrger54654654.png'

console.log(url.match(/https?:\/{2}[^\/]*/)[0]);

如果浏览器支持(IE 10及更高版本和最新浏览器),则可以使用

您只需这样做:

var test = new URL('http://192.168.6.1/Images/regrgrger54654654.png')
console.log(test.origin)
如果要使用正则表达式,则在这种情况下可以:

var url = 'http://192.168.6.1/Images/regrgrger54654654.png'

console.log(url.match(/https?:\/{2}[^\/]*/)[0]);

如果浏览器支持(IE 10及更高版本和最新浏览器),则可以使用

您只需这样做:

var test = new URL('http://192.168.6.1/Images/regrgrger54654654.png')
console.log(test.origin)
如果要使用正则表达式,则在这种情况下可以:

var url = 'http://192.168.6.1/Images/regrgrger54654654.png'

console.log(url.match(/https?:\/{2}[^\/]*/)[0]);

如果浏览器支持(IE 10及更高版本和最新浏览器),则可以使用

您只需这样做:

var test = new URL('http://192.168.6.1/Images/regrgrger54654654.png')
console.log(test.origin)
如果要使用正则表达式,则在这种情况下可以:

var url = 'http://192.168.6.1/Images/regrgrger54654654.png'

console.log(url.match(/https?:\/{2}[^\/]*/)[0]);

将答案扩展到:

将答案从以下方面扩展:

将答案从以下方面扩展:

将答案从以下方面扩展:


只需将字符串的一部分替换为另一个字符串:

var originalString = "http://192.168.6.1/Images/freferfer455ggg.png";
var newString = originalString.replace("http://192.168.6.1/","https://192.168.6.1/");
console.log(newString);

只需将字符串的一部分替换为另一个字符串:

var originalString = "http://192.168.6.1/Images/freferfer455ggg.png";
var newString = originalString.replace("http://192.168.6.1/","https://192.168.6.1/");
console.log(newString);

只需将字符串的一部分替换为另一个字符串:

var originalString = "http://192.168.6.1/Images/freferfer455ggg.png";
var newString = originalString.replace("http://192.168.6.1/","https://192.168.6.1/");
console.log(newString);

只需将字符串的一部分替换为另一个字符串:

var originalString = "http://192.168.6.1/Images/freferfer455ggg.png";
var newString = originalString.replace("http://192.168.6.1/","https://192.168.6.1/");
console.log(newString);

您可以使用正则表达式(纯JavaScript)来完成这项工作 例如,您可以使用

var ip = ''; // will contain the ip address
var ips = [] // ips is an array  that will contain all the ip address

var url = 'http://192.168.6.1/Images/Work3ererg.png';

url.replace(/http:\/\/(.+?)\//,function(all,first){
            // first will be something like 192.168.6.1
            // while all  will be something like http://192.168.6.1
            ip = first;
});

// url can be a a list of ip address in this case we should add the 
// g flag(which means global, not just the first match but all the matches )


url  ='http://192.168.6.1/Images/Work3ererg.png';
url +='http://192.168.6.2/Images/Work3ererg.png';

url.replace(/http:\/\/(.+?)\//g,function(all,first){
           ips.push(first);
});

您可以使用正则表达式(纯JavaScript)来完成这项工作 例如,您可以使用

var ip = ''; // will contain the ip address
var ips = [] // ips is an array  that will contain all the ip address

var url = 'http://192.168.6.1/Images/Work3ererg.png';

url.replace(/http:\/\/(.+?)\//,function(all,first){
            // first will be something like 192.168.6.1
            // while all  will be something like http://192.168.6.1
            ip = first;
});

// url can be a a list of ip address in this case we should add the 
// g flag(which means global, not just the first match but all the matches )


url  ='http://192.168.6.1/Images/Work3ererg.png';
url +='http://192.168.6.2/Images/Work3ererg.png';

url.replace(/http:\/\/(.+?)\//g,function(all,first){
           ips.push(first);
});

您可以使用正则表达式(纯JavaScript)来完成这项工作 例如,您可以使用

var ip = ''; // will contain the ip address
var ips = [] // ips is an array  that will contain all the ip address

var url = 'http://192.168.6.1/Images/Work3ererg.png';

url.replace(/http:\/\/(.+?)\//,function(all,first){
            // first will be something like 192.168.6.1
            // while all  will be something like http://192.168.6.1
            ip = first;
});

// url can be a a list of ip address in this case we should add the 
// g flag(which means global, not just the first match but all the matches )


url  ='http://192.168.6.1/Images/Work3ererg.png';
url +='http://192.168.6.2/Images/Work3ererg.png';

url.replace(/http:\/\/(.+?)\//g,function(all,first){
           ips.push(first);
});

您可以使用正则表达式(纯JavaScript)来完成这项工作 例如,您可以使用

var ip = ''; // will contain the ip address
var ips = [] // ips is an array  that will contain all the ip address

var url = 'http://192.168.6.1/Images/Work3ererg.png';

url.replace(/http:\/\/(.+?)\//,function(all,first){
            // first will be something like 192.168.6.1
            // while all  will be something like http://192.168.6.1
            ip = first;
});

// url can be a a list of ip address in this case we should add the 
// g flag(which means global, not just the first match but all the matches )


url  ='http://192.168.6.1/Images/Work3ererg.png';
url +='http://192.168.6.2/Images/Work3ererg.png';

url.replace(/http:\/\/(.+?)\//g,function(all,first){
           ips.push(first);
});

这些是字符串可能与我的图像源中的相同,我想用不同的图像文件名复制一些图像源可能与我的图像源中的相同,我想用不同的图像文件名复制一些图像源可能与我的图像源中的相同,我想用不同的图像文件名回复一些图像源可能与我的图像源中的字符串重复,我想用不同的图像文件名回复一些图像源