$regex1 = qr/(hello)/; # or $regex1 = '(hello)'; $test = 'hello there!'; print $1 if /$regex1/;