Bỏ qua đến nội dung

editor: batch replace in one field, also with regex

Chờ xử lý #anki #addon #editor #batch #replace #one #field
https://forums.ankiweb.net/t/editor-batch-multi-replace-official-thread/6778
24/12/2023

Cách tải addon editor: batch replace in one field, also with regex

Bạn có thể tải addon bằng một trong hai cách sau:

Click nút Copy bên dưới để copy code vào clipboard

356095608

Sau đó mở Anki → Tools → Add-ons → Get Add-ons → Dán code → OK

Mở trang addon trên AnkiWeb và tìm mã code ở cuối trang

Mở trên AnkiWeb

Cuộn xuống cuối trang AnkiWeb, tìm dòng có mã code 356095608 và copy

12

Mô tả chi tiết

You should adjust or at least check the default shortcut in the addon config. It’s difficult to find a shortcut that works for everyone: Windows and Mac have different built-in OS shortcuts and there are hundreds of addons with their own shortcuts. Keep in mind that on MacOS setting “Ctrl” in the addon config means that you actually need to use “Cmd”.

This add-on allows you to define a list of replacements and gives you a shortcut to apply all of these substitutions/replacements on the currently active field of the editor. Actually it’s two lists: plain text and regular expressions.

How this add-on works: -These replacements refer to the html source code of a field and not what you actually see. -My add-on uses python’s re.sub (regular expression matching operations similar to those found in Perl) to apply the regex replacements.

The code for the configuration window is taken from the great add-on Symbols As You Type by github.com/jefdongus.

For batch replacements there’s also the built-in find and replace functionality as well as glutanimate’s Batch Editing.

These do the opposite: They allow you to change      one thing about multiple fields and multiple notes whereas my add-on is about changing      multiple things in one field in one note.

If you find a bug let me know in the ankiweb forum (click the “Contact Author” button in the upper right of this window).

 

Versions

2023-12-24 fix for 23.10.1 or newer 2022-08-16 fix context menu entry, prefill dialog with selected text from editor 2021-12-18 fix bug reported in the forum 2021-12-11 fix for 2.1.50/qt6, replace longer strings first, option to remove most frequent abbreviation 2021-01-23 initial release


Liên kết hỗ trợ


Reviews (12)

👍 2025-05-18

event/全年节日 find:([a-z])/ replace:\1 / result:event / $1年节日 what i want :event / 全年节日

Comment from author answer to your first review: The problem your describing is expected behavior. As I stated in the description my add-on uses python’s re.sub to apply the regex replacements. To match a group use backslash notation (\1 and not $1), $1 should insert the literal string $1, see https://docs.python.org/3/library/re.html#index-26

answer to your second review which reads as of 2025-05-24: event/全

👍 2024-10-10

Neat add-on! One of my all time favorites

👍 2024-01-15

Great!

👍 2023-11-13

Hey man, thank you for sharing this. It is really helpful, notwithstanding take forever to I figure out that on the MacOS the key to bring up the REGEX interface is the CMD and not the CTRL. Thank you! BTW, worth to mention to other users that the shortcut to replace the field can be customized on the addon config section on Anki Addon interface.

👍 2023-05-29

Excellent Add-On!

However, I have a problem that I don’t think it could be tackled on a card to card basis. A deck of mine is consisted of over 9000 cards and I’d like to use the regex replacement your addon provides but to a specific field to all 9000 cards at the same time. I know that there’s the Find and Replace option in anki as a default option but this doesn’t let me to replace the regex inside a field. (it techinically does but for some specific reason an expression like this: ([ぁ-んー])

👍 2022-07-15

There is a typo in the description.

The link on glutanimate’s Batch Editing leads to Symbols As You Type instead. Comment from author thanks. It’s fixed now

👍 2022-06-21

Works well, thanks! I find it helpful for fixing Japanese Furigana, especially when it comes to names in novels

👍 2022-02-22

Amazing add-on. I have been trying to write my own add-on to delete clozes for my personal usage and was having a terrible time getting it to work. This addon is extremely elegant and well-made. It is absolutely crazy how versatile it can be!

👍 2022-02-22

Thank you!

That’s exactly what I was looking for

👍 2021-12-19

Works perfekt to get rid of ” ” or ”•”. Many thanks!

👍 2021-11-11

Great!

It would be good to know in advance that it uses rather Python-compatible than POSIX-compatible regex, so eg. one have to use rather \1 than $1 for backreferences. And that it operates rather on content that you see in HTML editor than on content you see normally in editor while adding/editing a note. It took me a while to figure it out. Comment from author thanks. I moved my sentence about the html source code being changed to a separate paragraph and added a sentence that python’s (sor

👍 2021-04-01

Exactly what I was looking for. Perfect for removing unwanted HTML (like  ) after pasting text from a website.