Results 1 to 2 of 2

Thread: Can someone explain how to use SplitRegExpr and TStrings?

  1. #1
    Join Date
    Oct 2010
    Posts
    36
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Can someone explain how to use SplitRegExpr and TStrings?

    I've looked through the tutorials, the examples, and whatever else I could find and I can't find any explanation how to use SplitRegExpr, beyond it choking when I pass it a TStrings variable, and it crashing when I don't...

    Any (working) examples someone can pass to me for SplitRegExpr?

  2. #2
    Join Date
    Jan 2008
    Location
    10° north of Hell
    Posts
    2,035
    Mentioned
    65 Post(s)
    Quoted
    164 Post(s)

    Default

    You can use this function =)

    TStrings are only abstract atm so you need to use TStringList

    Simba Code:
    program new;

    function SplitRegExprEx(Expr, Data: string): TStringArray;
    var
      DataArr: TStringList;
      I: integer;
    begin
      DataArr := TStringList.Create;
      try
        SplitRegExpr(Expr, Data, DataArr);
        SetArrayLength(Result, DataArr.Count);
        for I := 0 to DataArr.Count - 1 do
          Result[I] := DataArr.Strings[I];
      finally
        DataArr.Free;
      end;
    end;

    var
      S: TStringArray;

    begin
      S := SplitRegExprEx('[e|s|i]', 'Testing this little string');
      WriteLn('S := ' + ToStr(S) + ';');
    end.

    [offtopic]Woo I'm not a chicken anymore =P[/offtopic]

    Dg's Small Procedures | IRC Quotes
    Thank Wishlah for my nice new avatar!
    Quote Originally Posted by IRC
    [22:12:05] <Dgby714> Im agnostic
    [22:12:36] <Blumblebee> :O ...you can read minds

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •