Sha256: 40d22ec66c079d364a95c375056ded705418dbb5c946b44911696497bdbde3ba
Contents?: true
Size: 496 Bytes
Versions: 162
Compression:
Stored size: 496 Bytes
Contents
package igpay import ( "regexp" "strings" ) const testVersion = 1 var vowel = regexp.MustCompile(`^([aeiou]|y[^aeiou]|xr)[a-z]*`) var cons = regexp.MustCompile(`^([^aeiou]?qu|[^aeiou]+)([a-z]*)`) func PigLatin(s string) string { sw := strings.Fields(s) for i, w := range sw { l := strings.ToLower(w) if vowel.MatchString(l) { sw[i] = l + "ay" } else if x := cons.FindStringSubmatchIndex(l); x != nil { sw[i] = l[x[3]:] + l[:x[3]] + "ay" } } return strings.Join(sw, " ") }
Version data entries
162 entries across 162 versions & 1 rubygems