$regex = '(test)foo'; #but then to call it you must do $var =~ /$regex/;