1
我有令牌的列表,用于产生人造日语单词,看起来像这样:如何从已知标记列表中标记字符串?
var syllables = ["chi","tsu","shi","ka","ki","ku","ke","ko","ta","te","to","sa","su","se","so","na","ni","nu","ne","no","ha","hi","fu","he","ho","ma","mi","mu","me","mo","ya","yu","yo","ra","ri","ru","re","ro","wa","wo"];
鉴于像“yoniyotachihochinitarehakemukenushihofure”一词,是有可能把它分成单独的令牌到像阵列[“哟”,“你好”,“哟”...使用RegExps?
到目前为止,我有
var s="";
for(var i=0;i<syllables.length;i++)
s+=("("+syllables[i]+")");
s+="+";
console.log(s);
var splitregex = new RegExp(s,"gi");
console.log(str.split(splitregex));
和我回去 “[ 'yoniyotachihochinitarehakemukenushihofure']”
Al如此相关:http://thedailywtf.com/Articles/The-Automated-Curse-Generator.aspx – striking