内蔵の機能Delphiで文字列がサブが含まれていますが、あれば見つけることがありません最後には?
たとえば、次の文字列があるとします。
G15001、 G15005、 G15015、 G14015、 G14004、 PLU15010、 PLU14015
文字列がG15001G15005、G15015、PLU15010で、検索する部分文字列が15の場合はtrueを返したいのですが、G14015またはPLU14015の場合は最後に15しかないため、falseを返します。
Pos
部分文字列が見つかるかどうかを確認するために使用します。次に、部分文字列が最後に配置されていないことを確認します。
function ContainsBeforeEnd(const str, substr: string): Boolean;
var
P: Integer;
begin
P := Pos(substr, str);
if P = 0 then
// substr not found at all
Result := False
else
// found, now check whether substr is at the end of str
Result := P + Length(substr) - 1 <> Length(str);
end;
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加