# Note, tachyon, we need the /i modifier on each of these as well: my $job_desc = qr/\b national\s+security\s+adviser \s+/ix; my $title = qr/\b (?:dr\.|doctor) \s+/ix; my $f_name = qr/\b condoleeza \s+/ix; my $surname = qr/\b rice \b/ix; my $repl = 'condoleezarice'; $text =~ s/# Zero-width assertion: One of the options must follow: (?= $job_desc | $title | $f_name ) $job_desc ? # Option 1: job description $title ? # Option 2: title $f_name ? # Option 3: first name $surname # Surname -- not optional /$repl/gx;