| 
	
 | 
 Posted by Kim Madsen on 03/16/05 14:24 
-----Original Message----- 
From: Steve Slater [mailto:slater@handsonsecurity.com]  
Sent: Saturday, March 12, 2005 5:29 PM 
 
$name_array = explode(" ",$name); 
$short_name = "$name_array[0] " . end($name_array); 
 
> And a dozen other ways to do it I'm sure. I just finished a 
> project with a mess of pattern matching so have regex on the brain. :-) 
 
Hehe, I know the feeling 
 
Ereg solution: 
 
eregi("^([a-z] ).* ?([a-z])$", $name, $regs); 
print "the name in short is $regs[1] $regs[2]"; 
 
But when dealing with names I think Your approach is better since there´s all kinds of chararcters from language to language, in Denmark ÆæØøÅå, in sweden äÄöÖ and so on. Of course I could do something like: 
ereg("^(.+ ).* ?(.+)$", $name, $regs); // untested 
 
--  
Med venlig hilsen / best regards 
ComX Networks A/S 
Kim Madsen  
Systemudvikler 
Naverland 31 
 
DK-2600 Glostrup 
www.comx.dk  
Telefon: +45 70 25 74 74 
Telefax: +45 70 25 73 74 
E-mail: km@comx.dk
 
  
Navigation:
[Reply to this message] 
 |