I'm trying to create a function that retrieves a specific URL from an email HTML body.
The URL that I'm trying to retrieve with a regular expression has this form
https://dashboard.stripe.com/emails/receipts/invrc_1GYYpBFlgHQ8OfGyspnJivUe/pdf
So it has this pattern fixed https://dashboard.stripe.com/emails/receipts/invrc_ + alphanumeric string of 24 characters + fixed /pdf
I've tried this regular expression but it always print me "null"
var threads = GmailApp.search('subject:"Your receipt from Weglot"',0,1)[0];
var messages = threads.getMessages();
var body = messages[0].getBody();
var url = new RegExp(/https:\/\/dashboard.stripe.com\/emails\/receipts\/invrc_/+/[a-zA-Z0-9]+/+/\/pdf/)
var data = body.match(url)
Logger.log(data)
}
Has someone got an idea to fix this regular expression ?