简体   繁体   中英

Using the Flickr API

So I'm using the Flickr API. I want to show the username of the person who took the picture, looks like this nobody@flickr.com (theNameOfTheUser).

The thing is that I just want to show the actual username and exclude the e-mail. How can I do that?

www.johancarleborn.se to see what I mean.

newPic.innerHTML = "<div class='pic-container'> <p class='title'>" + result.items[i].title + "</p> <a href="+ result.items[i].link +" >  <img src=\'" + result.items[i].media.m + "\'> </a></div><p class='author'>" + result.items[i].author[19] + "</p><p class='published'>" + result.items[i].published + "</p>";

您可以使用Regexp,如下所示:

result.items[i].author[19].match(/\(([^)]*)\)/)[1]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM