Thank you all for your very accurate answers. Vincent.
> -----Original Message----- > From: John W. Krahn [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, September 18, 2002 7:08 PM > To: [EMAIL PROTECTED] > Subject: Re: Regexp > > > Sudarshan Raghavan wrote: > > > > On Wed, 18 Sep 2002, Panel Vincent - A53 wrote: > > > > > I have a problem with a regular expression : > > > > > > I process a text file with a list of names. > > > > > > I would like to reformat names like > > > > > > Francois de la Varenne > > > Macha Meril > > > Buzz Mac Cormack > > > > > > (there must be at least two words in the name) > > > to something like this : > > > > > > [EMAIL PROTECTED] > > > [EMAIL PROTECTED] > > > [EMAIL PROTECTED] > > > > > > In other words : "[EMAIL PROTECTED]". > > > > > > I tried the following thing and it doesn't work ($name > already contains one > > > of those names) : > > > > > > $name=~s/\s*(\w+)\s+(\w+)(\s+(\w+))*\s*/$1.$2$3\@domain.top/ > > > > Use split instead of a regexp (perldoc -f split) > > Let us assume the input string is in $str, this should do > the job for you > > > > my ($first, $rest) = split (/\s+/, $str, 2); > > $rest =~ s/\s+//g; > > print "$first.$last\@domain.top"; > > > Very good. Don't forget the OP wants it converted to lower case as > well. :-) > > my ( $first, $rest ) = map lc, split ' ', $str, 2; > $rest =~ s/\s+//g; > print "$first.$last\@domain.top"; > > > > John > -- > use Perl; > program > fulfillment > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]