Skip to content

Instantly share code, notes, and snippets.

@dev4dev
Last active November 17, 2018 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dev4dev/88a49dda9197a0ae3c5b81cac246e885 to your computer and use it in GitHub Desktop.
Save dev4dev/88a49dda9197a0ae3c5b81cac246e885 to your computer and use it in GitHub Desktop.
shit parser
const data = "https://res.cloudinary.com/indysigner/image/fetch/f_auto,q_auto/w_400/https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/1565855a-e53b-408b-b12f-b6f3115a8d84/3-accessible-presentations.jpg 400w,https://res.cloudinary.com/indysigner/image/fetch/f_auto,q_auto/w_800/https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/1565855a-e53b-408b-b12f-b6f3115a8d84/3-accessible-presentations.jpg 800w, https://res.cloudinary.com/indysigner/image/fetch/f_auto,q_auto/w_1200/https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/1565855a-e53b-408b-b12f-b6f3115a8d84/3-accessible-presentations.jpg 1200w, https://res.cloudinary.com/indysigner/image/fetch/f_auto,q_auto/w_1600/https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/1565855a-e53b-408b-b12f-b6f3115a8d84/3-accessible-presentations.jpg 1600w, https://res.cloudinary.com/indysigner/image/fetch/f_auto,q_auto/w_2000/https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/1565855a-e53b-408b-b12f-b6f3115a8d84/3-accessible-presentations.jpg 2000w";
function parse(shit) {
const reg = /([\w\W]+?) (\d+)w,?/igm
return shit.match(reg).map(function(line) {
return line.trim().split(' ')[0];
});
}
console.log(parse(data));
#!/usr/bin/env ruby
data = "https://res.cloudinary.com/indysigner/image/fetch/f_auto,q_auto/w_400/https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/1565855a-e53b-408b-b12f-b6f3115a8d84/3-accessible-presentations.jpg 400w,https://res.cloudinary.com/indysigner/image/fetch/f_auto,q_auto/w_800/https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/1565855a-e53b-408b-b12f-b6f3115a8d84/3-accessible-presentations.jpg 800w, https://res.cloudinary.com/indysigner/image/fetch/f_auto,q_auto/w_1200/https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/1565855a-e53b-408b-b12f-b6f3115a8d84/3-accessible-presentations.jpg 1200w, https://res.cloudinary.com/indysigner/image/fetch/f_auto,q_auto/w_1600/https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/1565855a-e53b-408b-b12f-b6f3115a8d84/3-accessible-presentations.jpg 1600w, https://res.cloudinary.com/indysigner/image/fetch/f_auto,q_auto/w_2000/https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/1565855a-e53b-408b-b12f-b6f3115a8d84/3-accessible-presentations.jpg 2000w"
result = data.gsub( /([\w\W]+?) (\d+)w,?/).map { |line| line.split(" ").first }
puts result
# Result
# https://res.cloudinary.com/indysigner/image/fetch/f_auto,q_auto/w_400/https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/1565855a-e53b-408b-b12f-b6f3115a8d84/3-accessible-presentations.jpg
# https://res.cloudinary.com/indysigner/image/fetch/f_auto,q_auto/w_800/https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/1565855a-e53b-408b-b12f-b6f3115a8d84/3-accessible-presentations.jpg
# https://res.cloudinary.com/indysigner/image/fetch/f_auto,q_auto/w_1200/https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/1565855a-e53b-408b-b12f-b6f3115a8d84/3-accessible-presentations.jpg
# https://res.cloudinary.com/indysigner/image/fetch/f_auto,q_auto/w_1600/https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/1565855a-e53b-408b-b12f-b6f3115a8d84/3-accessible-presentations.jpg
# https://res.cloudinary.com/indysigner/image/fetch/f_auto,q_auto/w_2000/https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/1565855a-e53b-408b-b12f-b6f3115a8d84/3-accessible-presentations.jpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment