I cannot for the life of me figure out how to leave only images in a field containing text, divs, and links.
i.e. I want to leave only images in this sample:
<div><i>Sketchy Pharmacology: Neuro/Psych</i></div><div><br></div><img src=“paste-46b12ecb3bd63c1b4e96e88da243520c18dfc491.png”><img src=“paste-7e3b87cad3a6e55ee2def26f8c5518def252a8c5.png”><br><a href=“something…hypnotics-melatonin-ramelteon?utm_source=anki&utm_medium=partnership&utm_campaign=february_update&utm_content=medical”>Watch Nonbenzodiazepine hypnotics, melatonin, ramelteon</a>"
I’m not sure that can be done with find&replace if the two may appear in an arbitrary order. You may have more luck exporting to a csv file, solving the problem with external tools/chatGPT, then importing your changes back in.
If done in multiple steps, maybe it will work. You could remove divs, then text, then links, etc. using separate regex expressions first (such as
</?a[^<>]+>). In the end only images will be left.
Okay. So through many steps I can get to:
text text text <img…>text text text
how can I find & replace the text outside of the <img…>
I gave a bad example. there are multiple <img> tags. so it’s more like:
asdlfkaj sdfl<img>adslfkaj <img>aldkjf aldfj
@dae was correct. can’t be done b/c anki uses rust regex, but doesn’t support lookbehind.
this particular problem has to be solved externally. excel’s formulas and sublime’s find/replace each had some kind of limiting feature. I ran out of time, but found a way to get the major problem I was trying to solve fixed. I’m sure a more typical regex with python would solve the img tag problem.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.