首先要引用StrUtils单元,即uses部分要加入StrUtils
函数的功能是返回子串 SubStr 在字符串 S 中的索引。可以指定查找起始位置Offset,默认从头开始查找,即Offset=1。
如果没有找到,返回0。如果指定的起始位置超过了字符串S的长度,或起始位置小于 1 ,也返回0。
StrUtils.PosEx Function
Returns the index value of a substring.
Pascal
function PosEx(const SubStr: string; const S: string; Offset: Integer = 1): Integer; overload;
Description
PosEx returns the index of SubStr in S, beginning the search at Offset. If Offset is 1 (default), PosEx is equivalent to Pos.
PosEx returns 0 if SubStr is not found, if Offset is greater than the length of S, or if Offset is less than 1.