我尝试了以下代码,该代码应该检查字符串是否包含空格,但出现错误。我还能怎么检查
if Index('some string',' ')>1 then begin
Result:= False;
end
else begin
Result := True;
end;
您可以使用pos函数。从文档:
pos函数返回子字符串在主字符串中的位置。如果主字符串中不存在子字符串,则返回值为0。
s:='note-book';
x:=pos('book',s); {x will be 6}
您可以在这里找到所有这些信息以及其他有用的技巧
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句