[英]how to replace \ with / using java script string functions
I have image path like this我有这样的图像路径
var str = "D:\Poc\testProject\DataPush\public\unzip\cust\AccountData\2.jpg"
this string throw error shown in image.此字符串抛出图像中显示的错误。 but when i remove unzip with extract it's work fine don't know why??
但是当我用提取物删除解压缩时它工作正常不知道为什么?
but when i do it's work fine but new issue start但是当我这样做时它工作正常但新问题开始
var str = "D:\Poc\testProject\DataPush\public\extract\cust\AccountData\2.jpg"
when i use replace
function of java script it's show result of below image.当我使用
replace
java 脚本的 function 时,它显示下图的结果。
basically i want output like this from above string.基本上我想从上面的字符串中像这样的 output 。
D:/Poc/testProject/DataPush/public/extract/cust/AccountData/2.jpg
As suggested in remove testProject output is same for str.replace('/\/g','/')
正如删除 testProject output 中所建议的那样,str.replace
str.replace('/\/g','/')
var str = D:\Poc\DataPush\public\extract\cust\AccountData\2.jpg
output is output 是
str.replace('/\\/g','/')
"D:PocDataPushpublicextractcustAccountData.jpg"
I think this will work我认为这会奏效
var stringReplaced = String.raw`D:\Poc\testProject\DataPush\public\unzip\cust\AccountData\2.jpg`.split('\\').join('/') console.log(stringReplaced);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.