描述
此函数返回STR中第一次出现的SUBSTR的位置,该位置从开头(从零开始)开始,或者从POSITION(如果指定)开始。
语法
以下是此函数的简单语法-
index STR, SUBSTR, POSITION index STR, SUBSTR
返回值
失败时此函数返回-1,否则返回匹配字符串的位置(第一个字符从零开始)。
例
以下是显示其基本用法的示例代码-
#!/usr/bin/perl $string = "That is test"; $index = index ($string, is); print "Position of is in the string $index\n";
执行上述代码后,将产生以下输出-
Position of is in the string 5
Perl 中的 index函数 - 无涯教程网无涯教程网提供描述此函数返回STR中第一次出现的SUBSTR的位置,该位置从开头(从零开始)开始,或者从POS...
https://www.learnfk.com/perl/perl-index.html














![[Leetcode] [Tutorial] 回溯](https://img-blog.csdnimg.cn/b704acb8f66d45eb9fb9c4bf7e2682e9.png#pic_center)




