[ILUG] regexp / php question
Kae Verens
kae at verens.com
Wed Aug 17 15:27:56 IST 2005
John P. Looney wrote:
>>$f=file('thefile.txt');
>>foreach($f as $ln){
>> $ln=str_replace(
>> array("'Looney'",'email at domain.com'),
>> array('<a href="thing?Looney">','a
>> href="mailto:email at domain.com"');
>>}
>
>
> Ah. I should have pointed out that the name and email can change on each
> line. That's the tricky bit. And I don't want just one thing replaced -
> i.e. if there is an email, without a name in quotes before it.
oh right. how about this:
$f=file('thefile.txt');
foreach($f as $ln){
$ln=preg_replace(
'/(\'([^\']*)\' <)?(([a-zA-Z0-9-]*)@
([a-zA-Z0-9-]*\.)+([a-zA-Z0-9-\.]*))/',
...er...
looks like you'll need to do it programmatically. Can't think how to do
that with a simple regexp
Kae
More information about the ILUG
mailing list