What are some resources or tutorials for learning and mastering regular expressions in PHP for data extraction tasks?

Regular expressions are powerful tools for pattern matching and data extraction in PHP. To learn and master regular expressions for data extraction tasks, resources such as the official PHP documentation on regular expressions, online tutorials on websites like W3Schools and Regex101, and books like "Mastering Regular Expressions" by Jeffrey E. F. Friedl can be helpful. Practice and experimentation with regular expressions in PHP code snippets will also aid in understanding and mastering this skill.

// Example PHP code snippet for using regular expressions to extract data
$string = "Hello, my email is example@email.com and my phone number is 123-456-7890.";
$pattern_email = '/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/';
$pattern_phone = '/\d{3}-\d{3}-\d{4}/';

preg_match($pattern_email, $string, $matches_email);
preg_match($pattern_phone, $string, $matches_phone);

$email = $matches_email[0];
$phone = $matches_phone[0];

echo "Extracted email: $email\n";
echo "Extracted phone number: $phone\n";