Last active
November 17, 2018 16:23
-
-
Save dev4dev/88a49dda9197a0ae3c5b81cac246e885 to your computer and use it in GitHub Desktop.
shit parser
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
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)); |
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
#!/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