Hide part of a field based on another field

I have a giant list of cards I mined through Yomichan that I want to make reverses of. The problem is, the dictionary I used for yomichan has the word itself in the definition. Going through each individual note to edit out the word from the backside would be too long for me to do, but I can’t use these cards when the answer is right in the front the second the card comes out.



I’ve been looking online to find some sort of HTML code I could use to specifically hide only the offending part of the field while keeping the rest of the definition in tact. I figured it has to be possible considering the text I want to hide itself exists in it’s own field by itself. Everything I’ve found online points to hiding the entire field and not just a single part of the field that contains part of a different field.

Code for front:

Code for back:

My note has 5 fields:

  1. Expression
    2: Meaning
    3: Reading
    4: Furigana
    5: Audio

Looking for a way to show the entire (2. Meaning) field with the exception of any instance that matches the (1. Expression) field.

Maybe try something like this

<div id="meaning" hidden>{{Meaning}}</div>
<div id="output"></div>

   var original_field = document.getElementById("meaning").innerHTML;
   var clozed_field = original_field.replace(/{{Expression}}/g, "...") ;
   document.getElementById("output").innerHTML = clozed_field; 

This is exactly what I’m looking for! Thank you so much, I am not good with HTML so you are a huge life saver for this!! :smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.