javascript在字符串中查找字符串
javascript finding a string in a string
我需要一个循环来检查字符串是否包含"''n"。
var content="你好''n bob''n ben je op deze ''n world ''n bobert",
我需要的是一个javascript(node.js)脚本,它检查String内容是否包含"''n"以及是否包含
它需要在"''n"字符上拆分,然后像这样打印
<content>Hello </content><br />
<content>bob </content><br />
<content>ben je op deze </content><br />
<content>world </content><br />
<content>bobert</content><br />
var content = "Hello 'n bob 'n ben je op deze 'n world 'n bobert";
var arr = content.split("'n");
var str = '';
arr.forEach(function(val){
str += '<content>'+val+'</content><br />';
})
$("div").html(str)
我不知道Node.js,但在javascript中,它可以使用split()来完成
var content = "Hello 'n bob 'n ben je op deze 'n world 'n bobert",
content_array = content.split("'n");
content_array.forEach(function(entry) {
document.write("<content>'+entry+'</content><br />");
});
相关文章:
- 在字符串中查找所有图像 src URL 并存储在数组中
- 用于查找子字符串的Regex
- 遍历DOM查找字符串有时会正确返回
- Javascript Regex,在字符串中查找数字
- 使用Regex查找URL中的特定字符串
- 在数组中查找某些字符串(Javascript)
- 查找并替换特定字符串
- 在从索引位置返回的字符串中查找空白
- 使用捕获组查找和替换json字符串中出现的所有短语
- 在Javascript中查找子字符串,并前置/附加一些字符
- 查找字符串及其索引中的最大数字
- 使用正则表达式查找字符串中的不匹配字符
- 如何更改字符串的查找方法
- 修复了如何在容器中查找和替换字符串的功能
- 通过包含的字符串查找对象
- 使用var和字符串查找文件夹
- 搜索字符串查找名称,并使用for循环记录每次出现的名称
- 二进制字符串查找
- 使用jquery和HTML字符串查找每个链接
- 按字符串查找对象索引