Skip to content

Instantly share code, notes, and snippets.

@mottet-dev

mottet-dev/utils.go

Created Jun 10, 2019
Embed
What would you like to do?
PriceFormat - Go Colly
package utils
import "regexp"
func FormatPrice(price *string) {
r := regexp.MustCompile(`\$(\d+(\.\d+)?).*$`)
newPrices := r.FindStringSubmatch(*price)
if len(newPrices) > 1 {
*price = newPrices[1]
} else {
*price = "Unknown"
}
}
func FormatStars(stars *string) {
if len(*stars) >= 3 {
*stars = (*stars)[0:3]
} else {
*stars = "Unknown"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.