Hello Everybody! I have a regex problem that I can't figure out. How can I get the first and last names of all people that has these letter tay in their name(s) using php-RegEX.
Here is a sample of my PhoneBook setup:
Dori Hanson:733-555-9501:25 E. Pine, Chicago, IL 60660
Evon Taylor:312-555-0706:29 W. Troy, Chicago, IL 60626
Lucy Bintay:312-555-2295:18 E. Lunt, Chicago, IL 60639
This is only one of many sequence I tried. This will print the entire line and not just the full name only which is what I am trying to do:
Code:
<?php
$fhandle=fopen("MyPhoneBook.txt", "r");
while( ! feof($fhandle)) {
$myBook= fgets($fhandle);
if (preg_match("/(tay)/i", $myBook))
{
echo "$myBook<br>";
}
}
fclose($fhandle);
?>
Thanks in advance
Last edited by mgraphic; 11-07-2011 at 10:34 AM..
Reason: edit sample phone numbers
|