/**
 * This function receives a string of text and a target word or phrase to search for.
 * It returns a list with the names of lawyers mentioned in the text that include the target.
 */
fun findLawyer(text: String, target: String): List<String> {

    val lawyerNames = mutableListOf<String>()
    var currentLawyer = ""
    var i = 0

    while (i < text.length) {  // Loop through each character in the text
        if (text[i].isLetter()) {  // Check if the current character is a letter
            currentLawyer += text[i]  // Add the character to the current lawyer name

            // Check if the current lawyer name is valid and includes the target
            if (currentLawyer.toLowerCase().contains(target.toLowerCase())) {
                lawyerNames.add(currentLawyer)  // Add the lawyer name to the list
                currentLawyer = ""  // Reset the current lawyer name
            }
        } else if (text[i] == ' ') {  // Check if the current character is a space
            currentLawyer = ""  // Reset the current lawyer name when encountering a space
        }

        i++  // Increase the index to move to the next character
    }

    return lawyerNames
}
/**
 * This function receives a string of text and a target word or phrase to search for.
 * It returns a list with the names of lawyers mentioned in the text that include the target.
 */
fun findLawyer(text: String, target: String): List<String> {
/**
 * This function receives a string of text and a target word or phrase to search for.
 * It returns a list with the names of lawyers mentioned in the text that include the target.
 */
fun findLawyer(text: String, target: String): List<String> {

    val lawyerNames = mutableListOf<String>()
    var currentLawyer = ""
    var i = 0

    while (i < text.length) {  // Loop through each character in the text
        if (text[i].isLetter()) {  // Check if the current character is a letter
            currentLawyer += text[i]  // Add the character to the current lawyer name

            // Check if the current lawyer name is valid and includes the target
            if (currentLawyer.toLowerCase().contains(target.toLowerCase())) {
                lawyerNames.add(currentLawyer)  // Add the lawyer name to the list
                currentLawyer = ""  // Reset the current lawyer name
            }
        } else if (text[i] == ' ') {  // Check if the current character is a space
            currentLawyer = ""  // Reset the current lawyer name when encountering a space
        }

        i++  // Increase the index to move to the next character
    }

    return lawyerNames
}