prassi has asked for the wisdom of the Perl Monks concerning the following question:
I need to do a particular text matching with the text "report" here is the example of the C code
#include <stdio.h> #include "report.h" void main() { #ifdef CHECK_REPORT report("This is good"); reports("This is also good") #endif #if defined (REPORT_ENABLE) report("This is not good"); #endif printf("The execution is completed\n"); }
In the above code I need to match all the report & reports statement and remove it the out put has to be like this
#include <stdio.h> #include "report.h" void main() { #ifdef CHECK_REPORT #endif #if defined (REPORT_ENABLE) #endif printf("The execution is completed\n"); }
but my perl code is not able to retain with the words starting with report_, when the line REPORT_ENABLE comes it blindly removes rest of the code. please suggest me the correction required in the regex in which I can retain even REPORT_ENABLE
s#\breport[s]?.*?\)\;|("[^"].*?")#defined $1 ? $1 :""#gsie;
regards,
-Prasad
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: text matching
by frozenwithjoy (Priest) on Jun 16, 2012 at 04:45 UTC | |
by prassi (Acolyte) on Jun 16, 2012 at 06:17 UTC | |
by frozenwithjoy (Priest) on Jun 16, 2012 at 06:30 UTC | |
by prassi (Acolyte) on Jun 16, 2012 at 06:54 UTC | |
by frozenwithjoy (Priest) on Jun 16, 2012 at 07:09 UTC | |
| |
by Cristoforo (Curate) on Jun 17, 2012 at 01:13 UTC |