1

So this function getLinkFromAws() will give me the value from the specific key that I input through the function in chrome, but apparently this regex is not supported in IE or Edge, so I wanted to see if there is another way to get the key value in regex that would support IE and Edge.

 var xmlDocumentString = '<?xml version="1.0" encoding="UTF-8"?><PostResponse><Location>https://wt-dev-user-files.s3.amazonaws.com/10003186%2F016acfd4187f4672aa27231fc9b1fa87_3d7ab98d0c4840039b0efbbc7c444db3.png</Location><Bucket>wt-dev-user-files</Bucket><Key>10003186/016acfd4187f4672aa27231fc9b1fa87_3d7ab98d0c4840039b0efbbc7c444db3.png</Key><ETag>"d303224a57cffe2557ebdf7e07c45b73"</ETag></PostResponse>';
   
 function getLinkFromAws(str, key) {
        var regex = new RegExp('(?<=<'+ key +'>).*(?=<\\/'+ key +'>)', 'gm');
        if(str.match(regex).length === 0 ){
          return "";
        }
        return str.match(regex)[0];
    }
    
   console.log(getLinkFromAws(xmlDocumentString, 'Key'));
NovaKid
  • 49
  • 7

0 Answers0