0

Hello Everyone,

As the title implies I need help extracting a name out of a string, my knolwedge of regular expressions is pretty limited. The strings I will be working with will look like this:

12345       Aragon  Denvil L.   123-1234    A123456 AragonD AragonAD@fake.mail.us   1000001234  ABC-ABC 123ABCD123  ABCD 1234 A1234 ABC12345A1  AB123AB 17-Feb-12   
54321   Mgmt    Chan    Jackie  123-4321    ABC4321 ChanJ   ChanJ@fake.mail.us  0   ABC-ABC 123ABCD123  ABCD 1234 A1234 ABC12345A1  AB123AB 17-Feb-12

From the first line I would be trying to extract "Aragon Denvil L." and from the second "Mgmt Chan Jackie". Worst case scenario I could maybe get away with just extracting "AragonD" and "ChanJ". I have managed to extract the emails and phone numbers from the strings, but no clue where to start for getting the names out.
Any and all help is greatly appreciated. Thanks in advance!

2
Contributors
2
Replies
9
Views
3 Years
Discussion Span
Last Post by deadsolo
0

I'm rubbish at regex. Maybe something like:

$str = "12345       Aragon  Denvil L.   123-1234    A123456 AragonD AragonAD@fake.mail.us   1000001234  ABC-ABC 123ABCD123  ABCD 1234 A1234 ABC12345A1  AB123AB 17-Feb-12";

$pattern = "/([^\d]+)/";

preg_match($pattern,$str,$matches);

$name = trim($matches[1]);

echo $name;
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.