Created
December 16, 2020 17:26
-
-
Save xrrocha/d6af00bab954210e27110f56f04e4dac to your computer and use it in GitHub Desktop.
code block for README-26
This file contains 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 wscrambler | |
object WordScrambler { | |
// Regex compiled only once: | |
// at object initialization. | |
// Inaccessible to others, | |
// even in the same package. | |
private val WORD_REGEX = | |
"""\p{IsLatin}(\p{IsLatin})\1*(?!\1)\p{IsLatin}\p{IsLatin}+""" | |
.toRegex() | |
fun scrambleWords(text: String):String { | |
// scrambling logic goes here... | |
} | |
} // object WordScrambler | |
// more package stuff ... | |
fun main() { | |
// Function called w/qualified name | |
println(WordScrambler.scrambleWords( | |
"I'm two with nature ― Woody Allen")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment