Consider
$email = "Name: John Smith
Phone: 1-888-555-5555
...";
Suppose I have the code above, and I need to filter the line after the word "Name: ". I have been doing:
if (preg_match("/Name:*? (.*)/m", $email, $g) === 1){
echo $g[1]."
"; //John Smith
}
What is a way to write the regex statement if the string didn't explicitly start with the word "Name: ", but one of 5 variations of it? Here are the five different formats I am working with:
- Name:
- Full Name:
- F. Name:
- First/Last Name:
- Name.