I am a Newbie and would like to know how I could do the following regex( really tried for half a day before posting this):
I need to parse a hardware code to pick and choose just the statements starting with "$fwrite(" and that ends with a ";". The coding has new-lines in between those statements, However I want them to be chosen too There are accidental "\n" in between the arguments of $fwrite which should be considered as a single line. When I tried doing :
#!/usr/local/bin/perl -w use strict; open(IN,"<ab.in"); while($_=<IN>) { if($_=~/\$display(.*?);$/i) { print; } } close(IN);
I get statements that have nested "fwrite" statements omitted in the o/p.
Eg. For the statement below:
the o/p is supposed to be:$fwrite(f,{few parameters},$fwrite(f,{kjg,kk})); $fwrite(f,koal,jirp); fwrite(f,jrei, orowp,jgo);
But the o/p that my code is producing instead is$fwrite(f,{few parameters},fwrite(f,{kjg,kk})); $fwrite(f,koal,jirp); fwrite(f,jrei,orowp,jgo);
$fwrite(f,koal, jirp);
In short, it is not recognizing fwrite statements that either have: a. a '\n' between its arguments b. nested fwrites.
Hope this is clear.. Can anybody please suggest a better solution.Thanks, Hari
In reply to A Question on Regex by Hari7
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |