Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package edu.example
- fun main() {
- val input = "test:value,password:secret,something:value"
- val passwordKey = "password:"
- var keyCurrentIndex = 0
- val result = CharArray(input.length)
- for (charIndex in input.indices) {
- if (keyCurrentIndex > 0 && input[charIndex] == ',') {
- keyCurrentIndex = -1
- }
- else if (keyCurrentIndex == passwordKey.length) {
- result[charIndex] = '*'
- continue
- }
- else if (keyCurrentIndex != -1 && input[charIndex] == passwordKey[keyCurrentIndex]) {
- keyCurrentIndex++
- }
- result[charIndex] = input[charIndex]
- }
- println(result)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement