#' Generate Regular Expression Pattern for Speaker Identification
#'
#' This function generates a regular expression pattern to identify lines
#' spoken by one or more specific speakers in an interview transcript.
#' The pattern is designed to match the speaker's name enclosed in square
#' brackets, followed by a space.
#'
#' @param speaker A character vector of speaker identifiers.
#'
#' @return A string containing the regular expression pattern. If multiple
#'   speakers are provided, the patterns are combined using the "|" (OR)
#'   operator to match any of them.
#'
#' @examples
#' 
#' speakers = retrieve_speaker(intrw)
#' pattern = generate_speaker_pattern(speakers)
#'
#' @family process interview
#' 
#' @export

generate_speaker_pattern = function(speaker){
    pattern = sprintf("\\[%s\\] ", speaker)
    if(length(speaker) > 1){
        pattern = paste0(pattern, collapse = "|")
    }
}