Last active
January 22, 2019 08:24
-
-
Save sizovs/abad97d830e5798fc88354648042d2a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const getAuthorName = flickrAuthor => { | |
const ALL_POSSIBLE_BRACKETS = /[{()}]/g | |
const VERTICAL_BAR = /^"|"$/g | |
const [_, name] = flickrAuthor.split(' '); | |
return name | |
.replace(ALL_POSSIBLE_BRACKETS, '') | |
.replace(VERTICAL_BAR, ''); | |
} | |
// flickr author is in format: | |
// "[email protected] (\"nick33333\")" | |
// | |
export const getAuthorNameV2 = flickrAuthor => { | |
const rx = /\((.+)\)/g; | |
const [_, name] = rx.exec(flickrAuthor); | |
return name; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment