John P. Looney wrote:
> This is a trick7y one, that slightly hurts my head. I'm wondering is
> there an easy way that I don't know of, to solve this:
>> I have a text file, with zero or more patterns like:
>> send an email to 'Looney' <email at domain.com> and tell him about it.
>> I'd like to replace 'Looney' with <a href="thing?Looney"> and
>email at domain.com with a href="mailto:email at domain.com". It's a simple
> regexp, but it has to be done many times.
>> Do I have to loop over all the text file, line by line, or is there
> something that'll do that for m e?
$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"');
}
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!