Skip to content

Instantly share code, notes, and snippets.

@sizovs
Last active January 22, 2019 08:24
Show Gist options
  • Save sizovs/abad97d830e5798fc88354648042d2a3 to your computer and use it in GitHub Desktop.
Save sizovs/abad97d830e5798fc88354648042d2a3 to your computer and use it in GitHub Desktop.
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