I can delete a layer by name:
var myDoc = app.activeDocument;
var myLayers = myDoc.layers;
var myLayer = myLayers["layer name"];
myLayer.remove();
or by stacking order:
var myLayer = myLayers[1];
myLayer.remove();
and I know how to find and replace text with a script so I am trying to find a way to combine these two and find a string, then delete the layer that string is on since I can't use the layer name or stacking order. I am trying to learn scripting as I go so this may not be possible (then someone saying it's not possible would be helpful) and my script is probably full of issues...but this is what I tried to put together and it doesn't work so here I am asking for help.
var myDoc = app.activeDocument;
var search_string = "words I am trying to search for";
var text_frames = myDoc.textFrames;
if (text_frames.length > 0)
{
for (var i = 0 ; i < text_frames.length; i++)
{
var this_text_frame = text_frames[i];
if (this_text_frame = search_string.contents)
{
this_text_frame.remove();
}
}
}