<?
/**
^ beginning of line
$ end of line
. any character
? zero or one time proceding
+ one or more time proceding
* zero or more of proceding
| union, like.. ABC|DEF means ABC or DEF
[abc] or [a-z] single character within
[^abc] matches any character NOT within
a{min,max} - a{3,5} matches aaa, aaaa and aaaaa
(ABC|DEF) - capture group

character classes:
\w - alphanum and underscore
\d - digits
\D - non digits
\s - whitespace
\S - non whitespace
*/

$text[] = "21:14:34 <oldkasper> marry me? <elena> no!";
$text[] = "21:14:50 <youngkasper> how about it? <elena> OMG nooooooooooooooooo!";

foreach( 
$text as $t => $v )
    
preg_replace_callback'/^(\d\d:\d\d:\d\d)\s+<youngkaspeR>.*<elena>\s+OMG\s+(no+!)$/'preg_cb$v ) . "\n";

// array, 0=> entire line, 1=> first capture group (timestamp), 2=> second capture group (noo!)
function preg_cb$m )
{
  
print_r($m);
  return 
str_replace$m[2], "YES! i thought you would never ask! YES!"$m[0] );
}

//print_r($text)

echo "\n\nYou are now forgiven ;)\n";

?>