I would like to extract a substring from an s3 URL using Regex rather than with string manipulation functions.
My requirement is to retrieve dynamodbtablename/05abd315-2e0b-4717-919d-1cc6576ebe19
out of a URL s3://s3bucket/dynamodbtablename/05abd315-2e0b-4717-919d-1cc6576ebe19
However, I have not been able to arrange the regex expression to give me what I want.
I would like the regex to parse in this form but I know that I am missing something in the regex line.
const url = 's3://s3bucket/dynamodbtablename/05abd315-2e0b-4717-919d-1cc6576ebe19';
const patternMatches = url.match(new RegExp(s3://${s3bucket}/${dynamodbtablename}/([a-f\d-]+)));
const migrationDataFileS3Key = patternMatches[indexOfResultingArrayWithDesiredSubstring]
I was able to come up with the expression below to retrieve the UUID/GUID and have had to concatenate it with ${s3bucket} to form the S3 bucket key. However, I am not happy with this solution. I require the above.
const url = 's3://s3bucket/dynamodbtablename/05abd315-2e0b-4717-919d-1cc6576ebe19';
const patternMatches = url.match(/([a-f\d-]+)/g);
const migrationDataFileS3Key = massiveTableItem + '/' + patternMatches[patternMatches.length - 1];
Thank you very much for your help.