Hel*_*los 37 string perl string-matching
我想使用curl来查看页面的来源,如果该源包含与该字符串匹配的单词,那么它将执行打印.我该怎么办if $string contains?
在VB中它就像.
dim string1 as string = "1"
If string1.contains("1") Then
Code here...
End If
Run Code Online (Sandbox Code Playgroud)
类似的东西,但在Perl中.
Eug*_*ash 90
如果您只需要在另一个字符串中搜索一个字符串,请使用该index函数(或者rindex如果您想从字符串的末尾开始扫描):
if (index($string, $substring) != -1) {
print "'$string' contains '$substring'\n";
}
Run Code Online (Sandbox Code Playgroud)
if ($string =~ m/pattern/) {
print "'$string' matches the pattern\n";
}
Run Code Online (Sandbox Code Playgroud)
Sea*_*ght 29
if ($string =~ m/something/) {
# Do work
}
Run Code Online (Sandbox Code Playgroud)
something正则表达式在哪里.
| 归档时间: |
|
| 查看次数: |
207284 次 |
| 最近记录: |