如何只获取此文本
abc-test-bucket.s3.ap-south-1.amazonaws.com/test-Service/0022JUN_29O00190_126072.pdf
从这个url
https://s3.ap-south-1.amazonaws.com/abc-test-bucket/test-service/https%3A/%2Fabc-test-bucket.s3.ap-south-1.amazonaws.com/test-Service/0022JUN_29O00190_126072.pdf
使用regex肯定有更有效的方法可以做到这一点。
此方法假设最后一个带有%符号的查询参数有2个字符,我们使用substring((删除这些字符
const inputString = "https://s3.ap-south-1.amazonaws.com/abc-test-bucket/test-service/https%3A/%2Fabc-test-bucket.s3.ap-south-1.amazonaws.com/test-Service/0022JUN_29O00190_126072.pdf";
let subs = inputString.split("%");
let whatWeWant = subs[subs.length-1].substring(2);
console.log(whatWeWant);