博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
字符串search()方法
阅读量:2503 次
发布时间:2019-05-11

本文共 625 字,大约阅读时间需要 2 分钟。

Return the position of the first occurrence of the string passed as parameter in the current string.

返回作为参数传递的当前字符串中第一次出现的字符串的位置。

It returns the index of the start of the occurrence, or -1 if no occurrence is found.

它返回事件开始的索引,如果没有发现,则返回-1。

'JavaScript'.search('Script') //4'JavaScript'.search('TypeScript') //-1

You can search using a regular expression (and in reality, even if you pass a string, that’s internally and transparently used as a regular expression too).

您可以使用正则表达式进行搜索(实际上,即使您传递了一个字符串,该字符串也在内部和透明地用作正则表达式)。

'JavaScript'.search(/Script/) //4'JavaScript'.search(/script/i) //4'JavaScript'.search(/a+v/) //1

翻译自:

转载地址:http://qxqgb.baihongyu.com/

你可能感兴趣的文章
Windows 8.1 应用开发 – 触控操作
查看>>
PowerDesigner创建物理模型
查看>>
使用Git、Git GUI和TortoiseGit
查看>>
vue---canvas实现二维码和图片合成的海报
查看>>
检查项目里是否有IDFA的方法
查看>>
64位系统使用Access 数据库文件的彻底解决方法
查看>>
注释,字符串
查看>>
性能瓶颈
查看>>
cmd 导入数据库
查看>>
Makefile书写注意事项--个人择记(一)
查看>>
文件转码重写到其他文件
查看>>
场景3 Data Management
查看>>
Dubbo入门---搭建一个最简单的Demo框架(转)
查看>>
树结构练习——排序二叉树的中序遍历
查看>>
AC自动机模板
查看>>
python 基本语法
查看>>
Oracle JDBC hang on
查看>>
inotify+rsync实现实时热备
查看>>
C#杂问
查看>>
Cocoapods的使用教程
查看>>