gpt4 book ai didi

pascal - 如何检查字符串是否在Pascal中包含字符串

转载 作者:行者123 更新时间:2023-12-04 05:18:11 25 4
gpt4 key购买 nike

我尝试了以下代码,该代码应该检查字符串是否包含空格,但出现错误。
我还能怎么检查

if Index('some string',' ')>1 then begin
Result:= False;
end
else begin
Result := True;
end;

最佳答案

您可以使用 pos 函数。从文档中:

The pos function returns the position of a substring in a main string. If the substring does not exist in the main string, then the returned value will be 0.


s:='note-book';
x:=pos('book',s); {x will be 6}

所有这些信息以及其他有用的技巧,您都可以找到 here

关于pascal - 如何检查字符串是否在Pascal中包含字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22047632/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com