Option to Set How Many Times Each MP3 Plays During Auto Advance

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…:sweat_smile:

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

:sweat_smile:

I expected this!

Maybe there is an addon which supports look around and back references.

1 Like

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.

1 Like

The duplicates were made a few years ago in my old cards .:grinning_face_with_smiling_eyes:

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.

2 Likes

I have made it by notepad++ already, Thank you very much, bro.
I’m really grateful for your awesome support!:grinning_face_with_smiling_eyes: :grinning_face_with_smiling_eyes: :grinning_face_with_smiling_eyes:

1 Like

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