es6如何利用正则表达式在字符串里找到指定值,下面web建站小编给大家详细介绍一下介绍正则表达式的运用方法!
match的运用
复制代码var string = "foo",
exp = /oo/;
var result = string.match(exp);
console.log(result); //['oo', index: 1, input: 'foo', groups: undefined]
- 1
- 2
- 3
- 4
test的运用
复制代码var string = "foo",
exp = /oo/;
var result = exp.test(string);
console.log(result); //true
- 1
- 2
- 3
- 4
search的运用
复制代码var string = "foo",
exp = /oo/;
var result = string.search(exp);
console.log(result); // 1,搜索不到返回-1
- 1
- 2
- 3
- 4
标签: match, search, test, 正则表达式
上面是“es6如何利用正则表达式在字符串里找到指定值”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_3260.html
workflows工作流
沙漠里一只红黑相间的蝎子
森林里一只邪恶的树妖ComfyUI工作流
梦幻中的一只猫咪ComfyUI工作流
完整海报生成comfyui工作流
一只可爱的雪豹在雪地里散步ComfyUI工作流
一名男子跪在月球岩石表面看见小行星碰撞
丛林里坐着一尊佛像
金色玫瑰花comfyui工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!