问题描述
我需要一个脚本或正则表达式(我将使用Javascript / jQuery来检查网站上的表单输入)以检查是否有人输入了大部分是乱码的单词。
I need a script or regex (which I will be using with Javascript / jQuery to check form input on a website) to check if someone has entered words which are mostly gibberish.
正常的单词或句子应通过测试:
Normal words or sentences should pass the test:
This is a normal sentence (pass)
Peterborough (pass)
这样的字样应该不通过测试:
Words like this should fail the test:
bfygrydyyisg (fail)
hjrrjmsjsinz (fail)
yqymuqawsioy (fail)
我想连续使用大约6个辅音或元音的支票,但上面的最后一个例子仍然是通过,我知道像'节奏'这样的英语单词会失败(尽管不太可能需要)。
I'd thought of using a check of around 6 consonants or vowels in a row, but the last example above would still pass and I know some english words like 'rhythms' would fail (although that is very unlikely to be needed).
任何想法?谢谢!
推荐答案
我最近遇到了同样的问题。基本上我们需要找出表单字段是否包含乱码答案。我们希望快速检测到这一点(以免减慢表格填充速度)并轻推用户提供正确的答案。
I run into this same problem just recently. Basically we needed to find if the form fields contained gibberish answers. We wanted to detect this fast (so as to not slow down form filling) and nudge the user to provide proper answers.
有一些新的前端和后端库正在进行此检测。
There are some newish front-end and backend libraries doing this detection.
- 相当自我描述
- Aptly命名为
- 在Python中还有:
- https://www.npmjs.com/package/gibberish-detector fairly self describing
- Aptly named https://www.npmjs.com/package/asdfjkl
- In Python there's also: https://github.com/rrenaud/Gibberish-Detector
希望这有助于其他人。
这篇关于Javascript脚本在表单输入中查找乱码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!