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
In reply to text matching by prassi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |