I am seeking for a regexp that finds a specific line break \n from a long String.
The specific \n is the one before a line that do not contains a specific char: '#'
As example:
This tis a fine #line1\nThis tis another fine #line2\nThis_belongs_to abobe line\nThis tis still is OK #line4
that represents the text:
this tis a fine #line1
this tis another fine #line2
this_belongs_to abobe line
this tis still is OK #line4
here the \n to be removed in the one after #line2, resulting in the text:
this tis a fine #line1
this tis another fine #line2this_belongs_to abobe line
this tis still is OK #line4
I came up with a regexp like: \n^(?m)(?!.*#).*$ that is close, but I can't figure out how to build the right one that allows me to match and remove only the right line break and preserve the remaining text/String.
Perhaps there is a better way than using regular expression?