Changeset 102 for trunk/NewView/StringUtilsUnit.pas
- Timestamp:
- Mar 26, 2007, 8:34:29 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/NewView/StringUtilsUnit.pas
r82 r102 16 16 StrLF = chr(10); 17 17 StrCRLF = StrCR + StrLF; 18 Quote = ''''; 19 DoubleQuote = '"'; 18 20 19 21 … … 43 45 // an optional escape character usable to escape field delimits. 44 46 // Example: 45 // StrExtractStrings('1x2x3\x4', "x", '\') ->46 // returns 4 strings: "1", "", "2" and "3x4"47 // StrExtractStrings('1x2x3\x4', 'x', '\') -> 48 // returns 4 strings: '1', '', '2' and '3x4' 47 49 Procedure StrExtractStrings(Var aResult : TStrings; Const aReceiver: String; const aSetOfChars: TSetOfChars; const anEscapeChar: char); 48 50 … … 68 70 Function StrLeft(const aString : String; const aCount : Integer) : String; 69 71 72 // Returns a copy of the string without aCount chars from right 73 Function StrLeftWithout(const aString : String; const aCount : Integer) : String; 74 75 // Returns a copy of the string including all characters until one from aSetOfChars found 76 Function StrLeftUntil(const aReceiver: String; const aSetOfChars: TSetOfChars) : String; 77 78 // returns true if the String starts with the provides one 79 // this is case SENSITIVE 80 Function StrStartsWith(const aReceiver: String; const aStartString: String): Boolean; 81 82 // returns true if the String starts with the provides one 83 // this is case INsensitive 84 Function StrStartsWithIgnoringCase(const aReceiver: String; const aStartString: String): Boolean; 85 70 86 // returns true if the String ends with the provides one 71 87 // this is case SENSITIVE … … 74 90 // returns true if the String ends with the provides one 75 91 // this is case INsensitive 76 Function StrEndsWithIgnoringCase(const a String: String; const anEndString: String): Boolean;92 Function StrEndsWithIgnoringCase(const aReceiver: String; const anEndString: String): Boolean; 77 93 78 94 // the IntToStr generates wrong results … … 82 98 83 99 Function BoolToStr(const aBoolean : boolean ): string; 100 101 // Returns aString enclosed in double quotes 102 Function StrInDoubleQuotes(const aString : String) : String; 84 103 85 104 … … 350 369 351 370 371 Function StrLeftWithout(const aString : String; const aCount : Integer) : String; 372 Begin 373 Result:= copy(aString, 1, length(aString) - aCount ); 374 End; 375 376 377 Function StrLeftUntil(const aReceiver: String; const aSetOfChars: TSetOfChars) : String; 378 Var 379 i : integer; 380 Begin 381 Result := aReceiver; 382 383 for i := 1 To Length(aReceiver) do 384 begin 385 if aReceiver[i] in aSetOfChars then 386 begin 387 Result := Copy(aReceiver, 1, i-1 ); 388 break; 389 end; 390 end; 391 end; 392 393 394 Function StrStartsWith(const aReceiver: String; const aStartString: String) : Boolean; 395 Var 396 tmpStringPos : integer; 397 tmpStartStringLength : integer; 398 Begin 399 tmpStartStringLength := Length(aStartString); 400 401 if Length(aReceiver) < tmpStartStringLength then 402 begin 403 result := false; 404 exit; 405 end; 406 407 for tmpStringPos := 1 to tmpStartStringLength do 408 begin 409 if aReceiver[tmpStringPos] <> aStartString[tmpStringPos] then 410 begin 411 result := false; 412 exit; 413 end; 414 end; 415 416 result := true; 417 end; 418 419 420 Function StrStartsWithIgnoringCase(const aReceiver: String; const aStartString: String) : Boolean; 421 Var 422 tmpStringPos : integer; 423 tmpStartStringLength : integer; 424 Begin 425 tmpStartStringLength := Length(aStartString); 426 427 if Length(aReceiver) < tmpStartStringLength then 428 begin 429 result := false; 430 exit; 431 end; 432 433 for tmpStringPos := 1 to tmpStartStringLength do 434 begin 435 if UpCase(aReceiver[tmpStringPos]) <> UpCase(aStartString[tmpStringPos]) then 436 begin 437 result := false; 438 exit; 439 end; 440 end; 441 442 result := true; 443 end; 444 445 352 446 Function StrEndsWith(const aReceiver: String; const anEndString: String): Boolean; 353 447 Var … … 384 478 tmpMatchPos : Longint; 385 479 Begin 386 tmpStringPos := length(a String);480 tmpStringPos := length(aReceiver); 387 481 tmpMatchPos := length(anEndString); 388 482 … … 395 489 while tmpMatchPos > 0 do 396 490 begin 397 if upcase(a String[tmpStringPos]) <> upcase(anEndString[tmpMatchPos]) then491 if upcase(aReceiver[tmpStringPos]) <> upcase(anEndString[tmpMatchPos]) then 398 492 begin 399 493 result := false; … … 406 500 result := true; 407 501 end; 502 408 503 409 504 Function LongWordToStr(const aLongWord: LongWord) : String; … … 450 545 end; 451 546 547 Function StrInDoubleQuotes(const aString : String) : String; 548 begin 549 Result := DoubleQuote + aString + DoubleQuote; 550 end; 551 552 452 553 END.
Note:
See TracChangeset
for help on using the changeset viewer.