#I want to remove this line.
#"#This line too"
puts "Hello, Ruby!" #Remove this comment alone.",,,,,....'''"#Consider this content too.
puts "############I don't want to remove this content bcoz it is in quotes#" #But remove this content.
puts "This is for testing ##sdfsfsf" ###Remove this content.
puts 'This is for testing ##testing' #I want to remove this content alone'
####
I have tried the following expression,
$_=~s/^#.*$//;
$_ =~ s/([^"|'](#)+.*[^"|'])\s*#.*$/$1/;
$_ =~ s/[^"|']#.*[^"|']$//;
####
Desired output:
puts "Hello, Ruby!" ",,,,,....'''"
puts "############I don't want to remove this content bcoz it is in quotes#"
puts "This is for testing ##sdfsfsf"
puts 'This is for testing ##testing'