Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching for Uppercase characters in a string 2

Status
Not open for further replies.

doctorjellybean

Programmer
May 5, 2003
145
0
0
I would greatly appreciate it if someone could provide a function to search for Uppercase characters in string, except the first one. This is what I need to do, search for Caps in a string, and when found, insert a space in front of it, e.g:

TheFantasticCollection to The Fantastic Collection

Thanks in advance.
 
Loop through the characters in your string, where s is a string and a is your loop counter you can say s[a] and the IsUpper() function to test if the character is upper case. Start the loop at the second char if you don't want to test it.

Steve: N.M.N.F.
If something is popular, it must be wrong: Mark Twain
 
Thank you.

Unfortunately, my knowledge of that kind of coding is virtually non-existent. So I'm still in the dark :)
 
Try something like this:

Code:
procedure TForm1.Button1Click(Sender: TObject);
var
  s: string;
  i: integer;
begin
  s := 'TheFantasticCollection';
  i := Length(s);
  while i > 1 do
    begin
      if IsUpper(s[i]) then
          Insert(' ', s, i);
      Dec(i);
    end;
  ShowMessage(QuotedStr(s));
end;

ps: you need to add "character" or "System.Character" to uses

Hope this helps.

[URL unfurl="true"]http://www.imoveisemexposicao.com.br/imobiliarias-em-guarulhos[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top