views:

75

answers:

3

hi, how can i remove a complete line if it's contain specific string like

#RemoveMe

thanks in advance

+1  A: 
str.indexOf("#RemoveMe") >= 0 // substring found

See doc.

hudolejev
+2  A: 

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.

CMS
A: 

@CMS

Thank you, it's work

Abdulrahman Ishaq
@Abdulrahman: Glad to help and welcome to StackOverflow. This should be a comment not an answer, also, if you are happy with an answer you can mark it as *accepted*, by clicking the green check icon below the arrows. Please give a look to the [faq](http://stackoverflow.com/faq) to see how StackOverflow works.
CMS