Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/369.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_Jquery_Html - Fatal编程技术网

JavaScript原始文本操作

JavaScript原始文本操作,javascript,jquery,html,Javascript,Jquery,Html,我需要处理原始文本: 我有这个,我需要这个:在这个原始文本列表中可以分配项目 _科克沃:官吏,(cpzh4)阿纳纳赛,(cre1l)鳞茎,(chk2m)塞布雷凯,(Ceburekai)ciyn3(Alus) 我知道在原始文本中总是这样_code:item 像这样的 官吏 阿纳纳赛 鳞茎 切布雷凯 阿勒斯 官吏 阿纳纳赛 鳞茎 切布雷凯 阿勒斯 如果您有文本字符串: var raw_text = "_cokwr: Mandarinai, _cpzh4: Ananasai, _cre1l: Bul

我需要处理原始文本:

我有这个,我需要这个:在这个原始文本列表中可以分配项目 _科克沃:官吏,(cpzh4)阿纳纳赛,(cre1l)鳞茎,(chk2m)塞布雷凯,(Ceburekai)ciyn3(Alus)

我知道在原始文本中总是这样_code:item

像这样的

官吏 阿纳纳赛 鳞茎 切布雷凯 阿勒斯 官吏 阿纳纳赛 鳞茎 切布雷凯 阿勒斯
如果您有文本字符串:

var raw_text = "_cokwr: Mandarinai, _cpzh4: Ananasai, _cre1l: Bulves, _chk2m: Ceburekai, _ciyn3: Alus";
然后可以使用拆分:

function splitArrayElements(element, index, array) {
  console.log(array[index].split(": ")[1]);
}
var list = raw_text.split(", ");
list.forEach(splitArrayElements);

mustache.js是你的朋友,如果你的绝地部队是Strong,那么你真正需要的就是使用正则表达式从你的输入文本创建项目,并使用jquery将其放在页面上。你需要保留_代码吗?如果不是,并且您的列表是一个字符串,请使用正则表达式替换str_,然后使用前缀和后缀替换字符串