Sha256: 219683521b1b15c66bb6ed36c6b5ba16e2fe62ebe71c8b2afc8c8a43caafc7bd
Contents?: true
Size: 519 Bytes
Versions: 139
Compression:
Stored size: 519 Bytes
Contents
object PigLatin { private val vowelRegex = "(^|\\s+)(a|e|i|o|u|yt|xr)(\\w+)".r private val consonantRegex = "(^|\\s+)(?<consonant>ch|qu|thr|th|sch|yt|rh|\\wqu|\\w)(?<rest>\\w+)".r private val vowelReplacement = "$1$2$3ay" private val consonantReplacement = "$1$3$2ay" def translate(phrase: String): String = vowelRegex.findFirstIn(phrase) match { case Some(x) => vowelRegex.replaceAllIn(phrase, vowelReplacement) case None => consonantRegex.replaceAllIn(phrase, consonantReplacement) } }
Version data entries
139 entries across 139 versions & 1 rubygems