LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] regexp / php question

[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
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


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!
RSS Version
Powered by Dell