I have an html textarea that will have entries that can look like the following:
google.com
youtube.com word word
netflix.com
twitch.tv
vimeo.com word
soundcloud.com word word
I want to make a feature that will search through the list for a url and delete all entries of it. To do this, I first need a regex to find the first occurrence. Note that I only need and want to find the first occurrence.
The feature must only delete an exact match. That is,
DeleteEntry("youtube.com");
should NOT delete the second line, but
DeleteEntry("youtube.com word word");
should.
So basically, I need to match this pattern
(beginningOfString OR newlineChar) then (anyWhiteSpaceExceptNewline) then (ENTRY) then (anyWhiteSpaceExceptNewline) then (endOfString OR newlineChar)
This is what I have so far
var expression = "\n|^[ \f\r\t\v]*" + entry + "[ \f\r\t\v]*\n|$";
var match = listbox.value.match(expression);
It doesn't seem to work the way I'm expecting it to.