Last active
September 1, 2016 13:59
-
-
Save kastoestoramadus/222197419f52e497061ae9f2a081b85e to your computer and use it in GitHub Desktop.
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
Replace all numbers with that number of '?': | |
java like: | |
import java.util.regex.Pattern | |
val NKasString = "?" | |
val p = Pattern.compile("[0-9]+") | |
val m = p.matcher("\"a2a12a2\"") | |
val sb = new StringBuffer() | |
while (m.find()) { | |
val found = m.group() | |
m.appendReplacement(sb, NKasString * found.toInt) | |
} | |
m.appendTail(sb) | |
println(sb.toString()) | |
scala like: | |
println( | |
"[0-9]+".r.replaceAllIn( | |
"\"a2a12a2\"", m => NKasString * m.group(0).toInt) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment