#11 2015-10-05 19:32

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,370

Re: Insert blank space between lowercase and uppercase

WARNING: DO NOT POST YOUR QUESTIONS IN TOPICS THAT ARE YEARS OLD! START A NEW THREAD!

lanceru wrote:

"What if I only want to add a hyphen, before only the 2nd capitalized word?"

Below is a script which will do what you want.

Adjust "InsertBeforeCapitalizedWord" constant to insert a separator before 1,2,3,4,etc capitalized word.

const
  Separator = '_';
  InsertBeforeCapitalizedWord = 2;
var
  I, CaptializedWordCount: Integer;
begin
  CaptializedWordCount := 0;
  for I := 2 to Length(FileName) do
  begin
    if IsWideCharAlpha(FileName[I]) and IsWideCharAlpha(FileName[I-1]) then
      if IsWideCharUpper(FileName[I]) and IsWideCharLower(FileName[I-1]) then
      begin
        CaptializedWordCount := CaptializedWordCount + 1;
        if CaptializedWordCount = InsertBeforeCapitalizedWord then
        begin
          WideInsert(Separator, FileName, I);
          Break;
        end;
      end;
  end;
end.

Last edited by den4b (2015-10-06 09:50)

Offline

Board footer

Powered by FluxBB