i need to be able to remover certain lines from a text box

e.g. before
line 1
line 2
line 1
line 4
line 2
line 5
line 6
line 2
line 1

so when i type e.g. line 1 in a text box and hit enter i would like it to search the text box and remove what ever is in the text box including any doubles etc.

e.g. if i type line 1 in the text box 2 it remove all "line 1" lines
so after
line 2
line 4
line 2
line 5
line 6
line 2

any ideas?