JSFiddle - React, Tailwind, and code Playground
HTML
Search lines for:
<input type="text" id="addfield0" value="Sometimes|relevance|understand" style="width:100%; margin-top:10px;" />
<input type="button" style="margin-top:10px;" value="Remove Lines Containing..." onClick="if(document.getElementById('addfield0').value!='') {removelines('containing');}" />
<input type="button" value="Not Containing..." onClick="if(document.getElementById('addfield0').value!='') {removelines('notcontaining');}" />
<textarea id="input_output" style="width:100%; margin-top:10px; height:150px; resize:none;" wrap="off">Sometimes to understand a word's
meaning you need more than a definition.
At Your Dictionary we try to give you all of the tools
you need to really understand what the word means.
Seeing the word in a sentence can
provide more context and relevance.</textarea>
<textarea id="removed_box" rows="4" style="width:100%; margin-top:10px; height:150px; resize:none;" wrap="off"></textarea>
JavaScript
var cacherem = 'yes';
var enableregex = 'yes';
function makeregexp()
{
var regexpoutarr = new Array();
var regexpout = '';
return regexpout;
}
function removelines(whatlines){
var textin = document.getElementById('input_output').value.replace(/\r/g,'');
var toremove = makeregexp();
var textinarr = textin.split('\n');
var textinarrcnt = textinarr.length;
var textoutarr = new Array();
var textoutarrcnt = 0;
var linesremovedcnt = 0;
var casen = 'i';
if(enableregex == 'yes') toremove = document.getElementById('addfield0').value; else toremove = makeregexp();
var killfun = 'no';
try
{
var toremoveregx = new RegExp(toremove,casen);
}
catch(err)
{
alert('Something is incorrect (' + err + ') within your regular expression.\nBe sure special characters .*+?^=!:${}()|\\ used as literals have been escaped with a backslash.');
killfun = 'yes';
}
if(killfun == 'no')
{
if(whatlines == 'containing' && cacherem == 'no')
{
for(var x=0;x<textinarrcnt;x++)
{
if(toremoveregx.test(textinarr[x]) == false)
{
textoutarr[textoutarrcnt] = textinarr[x];
textoutarrcnt++;
}
else
linesremovedcnt++;
}
}
if(whatlines == 'notcontaining' && cacherem == 'no')
{
for(var x=0;x<textinarrcnt;x++){
if(toremoveregx.test(textinarr[x]) == true)
{
textoutarr[textoutarrcnt] = textinarr[x];
textoutarrcnt++;} else linesremovedcnt++;
}
}
var removedcachearr = new Array();
if(whatlines == 'containing' && cacherem == 'yes')
{
for(var x=0;x<textinarrcnt;x++){
if(toremoveregx.test(textinarr[x]) == false)
{
textoutarr[textoutarrcnt] = textinarr[x];
textoutarrcnt++;
}
else
{
removedcachearr[linesremovedcnt] = textinarr[x]; linesremovedcnt++;
}
}
}
if(whatlines == 'notcontaining' && cacherem == 'yes')
{
for(var x=0;x<textinarrcnt;x++)
{
if(toremoveregx.test(textinarr[x]) == true)
{
textoutarr[textoutarrcnt] = textinarr[x];
textoutarrcnt++;
}
else
{
removedcachearr[linesremovedcnt] = textinarr[x]; linesremovedcnt++;
}
}
}
var textout = textoutarr.join('\n');
document.getElementById('input_output').value =...