As far as I can see you aren't missing anything. 
perl -e '$a="foo [ 0 ] = function(1,2,3,4)"; $a=~/(\w+)\(/; print $1'
works great for me. =)

But you might think about using this:
perl -e '$a=" foo [ 0 ] = function (1,2,3,4)"; $a=~/\b(\w+)\b\s*?\(/;
print $1'

The zero width assertion \b and the non-greedy space collapse of \s*?
handle a few more simple cases.

Cheers!
--Brandon

On Tue, 2005-02-22 at 21:19, Jerry Preston wrote:
> Correction!
> 
> I am using /(\w+)\(/ and not /\(/.
> 
> Thanks,
> 
> Jerry
> 
> -----Original Message-----
> From: Jerry Preston [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, February 22, 2005 9:17 PM
> To: 'Perl Beginners'
> Subject: Regex c code
> 
> 
> Hi!
> 
> This seems to so simple, but I do not see what I am doing wrong.
> 
> I want to get the function name from a string of c code:
> 
> $line = "Func001( 1,2,3,4 )";
> 
> Using $line =~ /\(/;
> Gives $1 = Func001;
> 
> Works great, but not on the following
> 
> $line = "Var_name[ 0 ] = Func002( d,e,r,t,)";
> 
> Using $line =~ /\(/;
> Gives $1 = Var_name[ 0 ]=;
> 
> What am I missing?
> 
> Thanks,
> 
> Jerry
> 
>  
> 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to