Author: Jonas Bilinkevicius How to check for any lower case or space in a string Answer: 1 function ContainsLowerCaseOrSpace(AString: string): boolean; 2 var 3 MySet: set of char; 4 Len, Counter: integer; 5 begin 6 MySet := ['a'..'z', ' ']; 7 Len := Length(AString); 8 Result := Len <> 0; 9 Counter := 1; 10 while (not Result) and (Counter <= Len) do 11 begin 12 if AString[Counter] in MySet then 13 Result := True 14 else 15 Inc(Counter); 16 end; 17 end; 18 19 procedure AddSpaceBeforeUpperCaseCharOrNumber(var AString: string); 20 var 21 Counter: integer; 22 bLastIsNumber: boolean; 23 bLastIsUpper: boolean; 24 begin 25 Counter := Length(AString); 26 bLastIsUpper := False; {Assume the last character will never be an upper case} 27 bLastIsNumber := AString[Counter] in ['0'..'9']; 28 dec(Counter); 29 while Counter > 1 do 30 begin 31 if AString[Counter] in ['0'..'9'] then 32 begin 33 if not bLastIsNumber then 34 Insert(' ', AString, Counter + 1); 35 bLastIsNumber := True; 36 end 37 else 38 begin 39 if bLastIsNumber or bLastIsUpper then 40 begin 41 Insert(' ', AString, Counter + 1); 42 bLastIsNumber := False; 43 end; 44 bLastIsUpper := AString[Counter] in ['A'..'Z']; 45 end; 46 dec(Counter); 47 end; 48 end;