Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
|
prog:lazarus:types:string:comparaison_text [03/07/2021 17:04] thierry [Avec les Wildcards (*)] |
prog:lazarus:types:string:comparaison_text [03/07/2021 17:29] (Version actuelle) thierry [Comparer du texte] |
||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| - | ====== Comparer du texte ====== | + | ====== Comparaison Recherche de texte ====== |
| - | ===== Avec les Wildcards (*/?) ===== | + | ===== Comparaisons ===== |
| - | ==== IsWild ==== | + | |
| - | Declaration: function IsWild(InputStr, Wilds: string; IgnoreCase: Boolean): Boolean;\\ | + | * ''AnsiCompareText'' : Compare 2 ansistrings, case insensitive, ignoring accents characters. (Integer) |
| + | * ''AnsiCompareStr'' : Compare 2 ansistrings, case sensitive, ignoring accents characters. (Integer) | ||
| + | * ''CompareStr'' : Compare 2 ansistrings case-sensitively, ignoring special characters. (Integer) | ||
| + | * ''CompareText'' : Compare 2 ansistrings case insensitive (Integer) | ||
| + | * ''SameStr'' : Check whether 2 strings are the same, case insensitive (Boolean) | ||
| + | * ''SameText'' : Checks whether 2 strings are the same (case insensitive) (Boolean) | ||
| + | == CompareText == | ||
| + | <code delphi> | ||
| + | function CompareText(const S1, S2: string): Integer; overload; | ||
| + | function CompareText(const S1, S2: string; LocaleOptions: TLocaleOptions): Integer; overload; | ||
| + | </code> | ||
| + | Compare deux textes sans tenir compte des majuscules/minuscules | ||
| + | |||
| + | |||
| + | ==== Avec les Wildcards (*/?) ==== | ||
| + | == IsWild == | ||
| + | Declaration: ''function IsWild(InputStr, Wilds: string; IgnoreCase: Boolean): Boolean;'' | ||
| IsWild compare InputString with WildCard string and return True if corresponds. | IsWild compare InputString with WildCard string and return True if corresponds. | ||
| Ligne 13: | Ligne 29: | ||
| A* : words with >= 1 letters and A at the begin;\\ | A* : words with >= 1 letters and A at the begin;\\ | ||
| ? : one letter.\\ | ? : one letter.\\ | ||
| + | == FindPart == | ||
| + | Declaration: ''function FindPart(const HelpWilds, InputStr: string): Integer;'' | ||
| + | |||
| + | FindPart compares a string with '?' and another, returns the position of HelpWilds in InputStr. | ||
| + | |||
| + | FindPart example: | ||
| + | <code delphi> | ||
| + | var P: Integer; Wild: string; | ||
| + | begin | ||
| + | Wild := '?im'; | ||
| + | P := FindPart(Wild, 'Let him go'); | ||
| + | { here P = 5 } | ||
| + | end; | ||
| + | </code> | ||
| + | == Dans TStringList == | ||
| + | Dans la propertie TStringList.Filter, on peut utiliser les Wildcards (a creuser...) | ||
| + | ===== Recherches ===== | ||
| + | == Pos == | ||
| + | [[https://www.freepascal.org/docs-html/rtl/system/pos.html]] | ||
| + | |||
| + | Recherche la position d'un Substring dans un String. | ||
| + | |||
| + | |||
| ====== Sources & Ressources ====== | ====== Sources & Ressources ====== | ||
| + | * [[https://www.freepascal.org/docs-html/rtl/sysutils/comparetext.html]] | ||
| + | * [[https://www.freepascal.org/docs-html/rtl/sysutils/stringfunctions.html]] | ||