I need a perl substitution to remove only the comment in the line . That line may have '#' with in double quotes .I used the following ,
s/(^.*\".+?#.+?\".+?)(#.*)/$1/g
It works for ,
print " not a comment # not a comment " . "not a comment # not a comment" ; # It is a comment
but for the line like ,
print " not a comment # not a comment " . "not a comment # not a comment" ;
It gave the output ,
print " not a comment # not a comment " . "not a comment
It removes the text from the last '#' . Can any one give me the exact regular expression to solve this problem .
Thanks in advance .