my $foo = "bar road"; if ($foo =~ /\b\w+\s*(road)?/) { print "Matched:", $1, "\n"; }