Hi there.
I have a text file that stores some data on individual lines seperated by new line break or \n basically. here is an example.
hello there! how are you today? // line 1
i'm great. how are you? // line 2
some more text here // line 3
more text here // line 4
some more talking going on here // line 5
more talking going on here // line 6
even more talking going on // line 7
the length of this file is set to a max of 50 lines of data. However, the users can specify how many lines of the chat to display between 8-50. I'm creating a command that clears something inappropriate from the chat log. But stuck here.
I'd like some users to be able to use a command like this. /clear [term]. Where [term] is the input they would like to clear. Example. User jonny says some cuss word.
Jonny says: $)($ you man!!
the moderator would then type something like /clear [expletive] or /clear jonny (meaning they can clear a single line that contains the expletive, or clear all texts that jonny has said or that have his name in them)
So to break down what i need to figure out. I need to search the file for $input, and delete every line in the text file where $input is present at least once in the line. It could wind up deleting multiple lines or zero lines if the $input entered to search for and delete is not present.
any ideas? I have a subroutine that chops the text file to 50 lines and deletes the oldest line as the newest one comes in. But can't figure out how to manipulate this enough to make a new function that would do what I need to do.
any help is greatly appreciated.