/**
 * This function replaces a specific substring in a given text with a new substring using a while loop.
 *
 * @param text The original text
 * @param oldSubstring The substring to be replaced
 * @param newSubstring The new substring to replace the old one
 * @return The modified text with the replaced substring
 */
fun replaceSubstring(text: String, oldSubstring: String, newSubstring: String): String {

    var index = 0
    var result = ""

    while (index < text.length) {
        if (text.substring(index, index + oldSubstring.length) == oldSubstring) {
            result += newSubstring
            index += oldSubstring.length
        } else {
            result += text[index]
            index++
        }
    }

    return result
}
/**
 * This function replaces a specific substring in a given text with a new substring using a while loop.
 *
 * @param text The original text
 * @param oldSubstring The substring to be replaced
 * @param newSubstring The new substring to replace the old one
 * @return The modified text with the replaced substring
 */
fun replaceSubstring(text: String, oldSubstring: String, newSubstring: String): String {
/**
 * This function replaces a specific substring in a given text with a new substring using a while loop.
 *
 * @param text The original text
 * @param oldSubstring The substring to be replaced
 * @param newSubstring The new substring to replace the old one
 * @return The modified text with the replaced substring
 */
fun replaceSubstring(text: String, oldSubstring: String, newSubstring: String): String {

    var index = 0
    var result = ""

    while (index < text.length) {
        if (text.substring(index, index + oldSubstring.length) == oldSubstring) {
            result += newSubstring
            index += oldSubstring.length
        } else {
            result += text[index]
            index++
        }
    }

    return result
}