What is the best practice for extracting values from a string using regular expressions in PHP?

When extracting values from a string using regular expressions in PHP, it is best practice to use the `preg_match` function. This function allows you to specify a regular expression pattern to match against the string and extract the desired values. The extracted values can then be stored in an array for further processing.

$string = "Hello, my email is example@email.com";
$pattern = '/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/';
preg_match($pattern, $string, $matches);

$email = $matches[0];
echo $email;