Hey there!
I've been working on a project in PHP where I need to extract specific patterns from a string using regular expressions. While I am familiar with using a single regular expression pattern to match and extract a specific pattern, I'm wondering how I can incorporate multiple regular expressions in PHP.
To give you a bit of context, I have a string that contains various information such as names, addresses, phone numbers, and email addresses. I need to parse and extract each of these entities separately.
For example, I want to extract names using a pattern like: "/[A-Z][a-z]+ [A-Z][a-z]+/". Then, I want to extract phone numbers using a pattern like: "/\d{3}-\d{3}-\d{4}/". Finally, I need to extract email addresses using a pattern like: "/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/".
Now, my question is, how can I combine these different regular expressions in PHP to extract each entity separately from the given string? Is there a way to loop through the string and apply each regex pattern one by one?
I appreciate any guidance or sample code snippets you can provide to help me achieve my goal. Thanks in advance for your help!

Hey!
Oh, I remember struggling with this exact issue a while back. PHP's regular expressions can definitely be a bit tricky, especially when dealing with multiple patterns.
In my experience, one approach you can take is to use the `preg_match` function along with an associative array to capture different entities separately. This way, you don't need to loop through the string multiple times.
Here's an example to give you an idea:
By using `preg_match` with an associative array, you can directly assign the matches to their corresponding keys. This makes it easier to access each entity separately in a more organized manner.
I hope this alternative approach helps you out! If anyone knows of any other techniques or tips, feel free to chime in.