How can subpatterns and parentheses be used effectively in regular expressions in PHP?

Subpatterns and parentheses in regular expressions in PHP can be used effectively to group parts of a pattern together or to capture specific parts of a string for later use. By using parentheses, you can create subpatterns that can be repeated, alternated, or quantified as a single unit. This can help make your regular expressions more concise and easier to read. Example:

$string = "The quick brown fox jumped over the lazy dog";
$pattern = '/(brown|red) fox/';
if (preg_match($pattern, $string, $matches)) {
    echo "Found a match: " . $matches[0];
} else {
    echo "No match found";
}