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