I want to find all “strike” tags and replace them with “del” tags.
Regular “Find and replace” feature should work.
That worked, thanks!
Where can I find out more info about what (.*?) and $1 do?
Did you know to do that off the top of your head, or did you look in the manual?
[Searching - Anki Manual]
That’s regular expression syntax (specifically for Rust, the programming language that Anki uses for backend operations).
Regular expressions (also called “regex” or “RegEx”) are a way of specifying patterns in text. They are used to find, match, and manipulate text strings.
A regular expression consists of a sequence of characters that defines a search pattern. These characters can be ordinary characters (like “a” or “5”), or special characters (like “*” or “?”) that have a special meaning.
(.*?) creates a so-called capture group for arbitrary text between the <strike> tags, and with $1 we reference that group, i.e. we tell Anki to insert capture group 1 in the replacement.
Similar to JavaScript support in templates, this is an advanced feature of Anki that caters to the tech-savy userbase. Therefore you won’t find a tutorial on it in the manual.
If you’re interested to learn more, I can highly recommend https://regexr.com/ as a playground.
Before, Anki would use the following for color:
<font color="#aa00ff"><b>と思いきや</b></font>
Then I updated Anki in July of last year, from then it does color like this:
<span style="color: rgb(170, 0, 255);"><b>そばから</b></span>
Since it was an update, I am assuming the latter has some benefits?
So, using your code above, to change the old font tags to span tags:
Find
<font color="#aa00ff"><b>(.*?)</b></font>
Replace With
<span style="color: rgb(170, 0, 255);"><b>$1</b></span>
This would work, right? I guess I would also have to find both <font color="#aa00ff"><b> and <b><font color="#aa00ff">, since I probably bolded first sometimes.
I believe the color changes are an implementation byproduct rather than a deliberate change. Your example looks reasonable at first glance; when in doubt, create a backup first so you can revert if anything goes wrong.
