hi, how can i remove a complete line if it's contain specific string like
#RemoveMe
thanks in advance
hi, how can i remove a complete line if it's contain specific string like
#RemoveMe
thanks in advance
If you have a multi-line string, you could use a RegExp with the m
flag:
var str = 'line1\n'+
'line2\n'+
'#RemoveMe line3\n'+
'line4';
str.replace(/^.*#RemoveMe.*$/mg, "");
The m
flag will treat the ^
and $
meta characters as the beginning and end of each line, not the beginning or end of the whole string.