regex parse error: (?i)(\\\[sound:.\*?\\\])(?=\[\\s\\S\]\*\\1) ^^^ error: look-around, including look-ahead and look-behind, is not supported
However, it turned out like this…![]()
regex parse error: (?i)(\\\[sound:.\*?\\\])(?=\[\\s\\S\]\*\\1) ^^^ error: look-around, including look-ahead and look-behind, is not supported
However, it turned out like this…![]()
Hmmm, Anki doesn’t support look ahead?!
If they’re all clumped together like in your screenshot , you can use (\[sound:.*?\])\1\1\1 and replace it with ${1}. Make a backup first!
regex parse error: (?i)(\\\[sound:.\*?\\\])\\1\\1\\1 ^^ error: backreferences are not supported
![]()
I expected this!
Maybe there is an addon which supports look around and back references.
Btw how did you get these duplicates? If you have use my original regex, it would have surrounded the references with <span> tags.
If you did use my original regex, then I already gave you a way to change the number of audio references.
The duplicates were made a few years ago in my old cards .![]()
The only way I can think of to fix this is by exporting the deck as notes in plain text then modifying it with some external tools. Make a backup first!
For example, paste the following code (after modifying the PATH TO YOUR DECK APKG) into a text file, rename it to something like remove_duplicate_audio.py and run it:
import re
with open(r"PATH TO YOUR DECK APKG", r, encoding="utf-8") as f:
notes = f.read()
with open(r"PATH TO YOUR DECK APKG", w, encoding="utf-8") as f:
f.write(re.sub(r"(\[sound:.*?\])(?=[\s\S]*\1)", r"", notes))
After that, import the apkg file back.
Edit: this will probably remove all duplicate audio references, even those in different notes. It’s probably possible to limit it to notes, but I don’t have time for that right now.
I have made it by notepad++ already, Thank you very much, bro.
I’m really grateful for your awesome support!
![]()
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.