Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to check for any lower case or space in a string Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
19-Oct-02
Category
Object Pascal-Strings
Language
Delphi 2.x
Views
69
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			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;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC