If I understand you right and you want everything before the last comma in $derer in the string $Source, I would use:
if ($derer =~ /^(.*),/) { $Source = $1; } The first * is greedy and grabs everything from the beginning of the string to the last comma. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Thursday, December 27, 2001 1:09 PM To: [EMAIL PROTECTED] Subject: Re: $1, $2, $3 HI, I have a question. I want to extract all the information to the left of the last comma. If there are 3 commas I would like everything to the left of the third comma. $derer = "Seattle, Washington, USA, NAME"; ## I only need Seattle, Washington, USA if($derer =~ /(.*?),([.*?,]*)(.*)/g) { ## I figure Seattle is $1 Washington is $2 and USA is $3 ## I put ([.*?,]*) to tag if there is otherinformation and commas, as many times ## following the first one. This should be $2. print " \$1 = $1, \$2 = $2, \$3 = $3 \n"; ## $1 is Seattle $2 is blank $3 is Washington, USA $Source = $1 . " ". $2 ; } print "source = $Source \n"; ## Prints source = Seattle What am I doing wrong? Why is $2 blank? -- 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]