开发者

Get Unique Email Identifier from GMail URL

At the moment, I am coding an Google Chrome extension (in Javascript) which interfaces开发者_如何学Go with GMail. The extension needs to know the unique email identifier that is present at the end of every GMail URL.

Eg. https://mail.google.com/mail/#inbox/11a4ac0cg2bc3330 https://mail.google.com/mail/#label/Archived+Emails/11a4c8b472b03c87

What would be the best way to get this unique identifier using Javascript (through regex or otherwise, preferably in a function like this:

function getIdentifier(URL){ [Insert your magic here] return ID; }

Thanks,

DLiKS


this is based on your samples provided, if you're assured of the format, you can use .substirng() and .lastIndexOf(), like this:

function getIdentifier(URL){
  return URL.substring(URL.lastIndexOf('/') + 1);
}

You can give it a try here, this keeps it pretty simple, find the last /, move over one to exclude the / itself, take the rest of the string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜