perl的index命令,英文原样奉送,大家慢慢研读。
Syntax
index STR, SUBSTR, POSITION
index STR, SUBSTR
Definition and Usage
Returns the position of the first occurrence of SUBSTR in STR, starting at the beginning (starting at zero), or from POSITION if specified.
Return Value
-1 on failure otherwise Position of matching string (starting at zero for the first character).
Example
Try out following example:
It produces following result
Position of is in the string 5