Need help with script

Evgeni's Avatar

Evgeni

25 Apr, 2020 06:55 PM

Hi everyone. Maybe someone here could help me with JavaScript. I know little about JS. I’m using this script in my Japanese deck. It’s not mine I just copy-pasted it)

https://pastebin.com/pUFXQCHt

There are fields Meaning and Alternative Meanings in the card. Alternative Meanings can contain multiple words separated by commas. For example, kanji 下
Meaning: Down
Alternative Meanings: Below, Under, Beneath

This script accepts any word from alternative meanings (altmean) as correct answer. Also Input is case insensitive!
So here is the problem. It doesn’t work with Russian alphabet (cyrillic). I tried to change this line like this
var typedAnsDis = str2.replace(/[^A-Za-zА-Яа-яЁё0-9]/g, ' ') but it didn’t work.

What should I change to make it work with Cyrillic also? Thanks!

  1. 1 Posted by alexander on 26 May, 2020 11:03 PM

    alexander's Avatar

    Hei Evgeni,

    I don't know what the solution for your problem is but have you tried searching for `Cyrillic Regex`? Maybe this can give better hints on how to solve this.

    Also worth checking it out is the docs from MZDN[0]. If you have an example deck, I can try to debug this for you but it's kind of hard just reading the pastebin.

    [0]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions

Comments are closed, but you can start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac