Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript:在字符串中查找英语单词_Javascript_Node.js_Dictionary - Fatal编程技术网

Javascript:在字符串中查找英语单词

Javascript:在字符串中查找英语单词,javascript,node.js,dictionary,Javascript,Node.js,Dictionary,我想在一个字符串中找到任何英语单词(至少4个字母) Eg: hello123fdwelcome => ["hello", "welcome"]; 您能为我推荐任何与英文单词匹配的解决方案或javascript库吗 谢谢您可以使用这个单词列表 期望的输出是什么?@输入的第四位是:hello123fdwelcome;这不是一个问题。这是一个需求列表,有一个隐晦的需求。我想你会有一个源(例如一个表),其中包含所有要比较的有效单词,对吗?@anna我需要一个包含源的lib var input

我想在一个字符串中找到任何英语单词(至少4个字母)

Eg: hello123fdwelcome => ["hello", "welcome"]; 
您能为我推荐任何与英文单词匹配的解决方案或javascript库吗


谢谢

您可以使用这个单词列表


期望的输出是什么?@输入的第四位是:hello123fdwelcome;这不是一个问题。这是一个需求列表,有一个隐晦的需求。我想你会有一个源(例如一个表),其中包含所有要比较的有效单词,对吗?@anna我需要一个包含源的lib
var input = "hello123fdwelcome";
var fs = require('fs');
fs.readFile("words.txt", function(words) {
   var words = words.toString().split('\n').filter(function(word) {
       return word.length >= 4;
   });
   var output = [];
   words.forEach(word) {
       if (input.match(word)) {
           output.push(word);
       }
   });
   console.log(output);
});