Created
August 10, 2018 22:03
-
-
Save srph/f49ea1246f36ac0999c5b3d1c6c0e57a to your computer and use it in GitHub Desktop.
Go: Extract image from css style url
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
package main | |
import ( | |
"strings" | |
"regexp" | |
) | |
func getThumbnailFromStyle(style string) string { | |
r := regexp.MustCompile("url\\((.+)\\)") | |
return strings.TrimRight(strings.TrimLeft(r.FindString(style), "url("), ")") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment