在VB中会是这样。
dim string1 as string = "1" If string1.contains("1") Then Code here... End If
类似的东西,但在Perl。
index
rindex
if (index($string,$substring) != -1) { print "'$string' contains '$substring'\n"; }
要搜索字符串以寻找pattern匹配,请使用匹配运算符m//:
m//
if ($string =~ m/pattern/) { print "'$string' matches the pattern\n"; }