How to check if string contains string in Pascal

I tried the following code which supposed to check if a string contains spaces but I get an error. How else can I check that

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


  • You can use pos function. From documentation:

    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.

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

    All this information, and other useful tips you can find here