您现在的位置是:网站首页> 编程资料编程资料
PowerShell Contains函数查找字符串实例_PowerShell_
2023-05-26
498人已围观
简介 PowerShell Contains函数查找字符串实例_PowerShell_
本文介绍在PowerShell中使用字符串的Contains函数,来查询一个字符串中是否存在另一个字符串。
Contains()函数是从String对象中继承过来的,可以直接用于字符串的查找判断。Contains()函数的返回值是一个布尔值,即True或False,它表示的含义是存在或不存在。
举例如下:
“123“中存在1
复制代码 代码如下:
PS C:\Users\spaybow> "123".contains("1")
True
True
”123“中存在”12“
复制代码 代码如下:
PS C:\Users\spaybow> "123".contains("12")
True
True
”123“中存在123
复制代码 代码如下:
PS C:\Users\spaybow> "123".contains("123")
True
True
”123“中不存在”13“
复制代码 代码如下:
PS C:\Users\spaybow> "123".contains("13")
False
False
因为只是存在是否存在,所以Contains函数无法定位查询字符串在被查询字符串中的位置。如果需要定位它的位置,则需要使用到IndexOf函数,这个函数我们即将介绍。
关于PowerShell使用Contains函数查找字符串,本文就介绍这么多,希望对您有所帮助,谢谢!
您可能感兴趣的文章:
- 如何解决Mybatis--java.lang.IllegalArgumentException: Result Maps collection already contains value for X
- Python extract及contains方法代码实例
- javascript中contains是否包含功能实现代码(扩展字符、数组、dom)
- C#判断字符串中是否包含指定字符串及contains与indexof方法效率问题
- Oracle 中Contains 函数的用法
- jQuery使用contains过滤器实现精确匹配方法详解
- JavaScript中扩展Array contains方法实例
- jQuery实现contains方法不区分大小写的方法
- jQuery中:contains选择器用法实例
- Java contains用法示例
相关内容
- Windows Powershell 命令集 cmdlets_PowerShell_
- Windows Powershell 执行外部命令_PowerShell_
- Windows Powershell 进行数学运算_PowerShell_
- Windows Powershell 管道和重定向_PowerShell_
- Windows Powershell 快捷键介绍_PowerShell_
- windows Powershell 快速编辑模式和标准模式_PowerShell_
- Windows Powershell 自定义控制台_PowerShell_
- Windows Powershell 介绍和安装_PowerShell_
- Powershell学习笔记--使用正则表达式查找文件_PowerShell_
- Tornado中database模块被取消的替代方法_PowerShell_
