How can placeholders be used in regex patterns to replace varying characters in a string?

Placeholders in regex patterns can be used to match and replace varying characters in a string. By using placeholders like `.` to match any character or `[a-z]` to match any lowercase letter, we can create flexible patterns that can handle different inputs. These placeholders can be combined with literal characters to create more specific patterns for replacing text in a string.

// Example of using placeholders in regex patterns to replace varying characters in a string
$string = "Hello, World!";
$pattern = "/[aeiou]/"; // Match any vowel
$replacement = "*";
$new_string = preg_replace($pattern, $replacement, $string);
echo $new_string; // Output: H*ll*, W*rld!