Einzelnen Beitrag anzeigen

Benutzerbild von glkgereon
glkgereon

Registriert seit: 16. Mär 2004
2.287 Beiträge
 
#3

Re: Reguläre Ausdrücke...wie?

  Alt 16. Jun 2005, 13:30
das sieht sehr gut aus!!!

ich habe folgendes beispiel gefunden:

Delphi-Quellcode:
function ParsePhone (const AInputString, ATemplate : string) : string;
const
   IntPhoneRE = '(\+\d *)?(\(\d+\) *)?\d+(-\d*)*';
var
   r : TRegExpr;
begin
   r := TRegExpr.Create;
   try
      r.Expression := IntPhoneRE;
      if r.Exec (AInputString)
         then Result := r.Substitute (ATemplate)
         else Result := '';
      finally r.Free;
   end;
end;
begin
   ParsePhone ('Phone of AlkorSoft (project PayCash) is +7(812) 329-44-69',
   'Zone code $1, city code $2. Whole phone number is $&.');
   // Rückgabe: 'Zone code +7, city code (812) . Whole phone number is +7(812) 329-44-69.'
end.
jedoch auch mithilfe dieser Seite gelingt es mir nicht die function so umzubauen das ich sie für meine zwecke nutzen könnte

was ich möchte is einfach nur folgendes:
$1 + string + $2 + string
umsortieren im prinzip...also zb in
string + $2 + $1 + string

wie geht das?
»Unlösbare Probleme sind in der Regel schwierig...«
  Mit Zitat antworten Zitat