Re: Need to extract only the function name no brackets reqd.




I have this program which extract function names from the files.
My only problem is I want to extract only the function names{no
brackets () needed } .
Currently its extract all words after word sub but it all
returns
the parentheses after that.


Hello,

Given the function definition like below,

sub myfunc($,$){
....
}


You may extract the function name using the regex,

my ($func_name) = $_ =~ /sub\s+(\w+)/;

or even,

my ($func_name) = /sub\s+(\w+)/;

The 'split' is not needed I think.
.



Relevant Pages

  • RE: Need to extract only the function name no brackets reqd.
    ... Need to extract only the function name no brackets reqd. ... Currently its extract all words after word sub but it all ... You may extract the function name using the regex, ...
    (perl.beginners)
  • Need to extract only the function name no brackets reqd.
    ... I have this program which extract function names from the files. ... Currently its extract all words after word sub but it all ... print RES $subName."\n"; ...
    (perl.beginners)
  • RE: Extract the desired value from a regex
    ... Extract the desired value from a regex ... property of Persistent Systems Ltd. ... Systems Ltd. does not accept any liability for virus infected mails. ...
    (perl.beginners)
  • Re: Regex question
    ... structure of the date you're trying to extract. ... For example, in Regex you can ... pattern that will ensure a valid date within the range allowed by T-SQL ... valid date from a string. ...
    (microsoft.public.dotnet.languages.csharp)
  • regular expression extracting groups
    ... I'm trying to use regular expressions to help me quickly extract the ... regex groups that I can easily access later. ... the key/value pairs but it ends up with only the contents of the last ... GROUP_SCHEMA = 'schema' ...
    (comp.lang.python)