tags:

views:

86

answers:

3
re.findall(r'(\b[a-zA-Z][a-zA-Z0-9-]*)(?=\.com\b)', DATA)

how would this line be in PHP?

+4  A: 

I think you're looking for preg_match_all.

Josh Leitzel
no, preg_match_all returns the number of matches, not the strings that match themselves
GSto
Who said it didn't? It still gives you the matches via the $matches array reference.
Josh Leitzel
GSto, please read the link posted by Josh. As already mentioned: you're wrong. preg_match_all can be used just fine.
Bart Kiers
A: 

You might want to check out http://php.net/preg%5Fmatch%5Fall

Stephen Caldwell
no, preg_match_all returns the number of matches, not the strings that match themselves
GSto
That's wholly incorrect, sir. As seen in Felipe's response, the 3rd parameter to preg_match_all is the matches themselves.
Stephen Caldwell
+3  A: 

preg_match_all('/(\b[a-zA-Z][a-zA-Z0-9-]*)(?=.com\b)/',$data,$matches);

Felipe Ribeiro