in reply to Re^2: Regex to ignore comment
in thread Regex to ignore comment

Well if # can be both part of your pattern and an indication that it is a comment to be removed, then you need to specify how to distinguish between the two cases.

With an input string such as:

pattern = the number is #8 # number
this would remove everything after (and including) the last # of your string:
s/#[^#]+$//;
but this assumes that you always have a trailing comment in your input.

But we have not way to know whether it will work with your other input lines (i.e. if there is always a trailing comment in your lines).