DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Pascal and Delphi (http://www.daniweb.com/forums/forum124.html)
-   -   how to use RegexBuddy? can you help me. (http://www.daniweb.com/forums/thread201786.html)

MrBaseball34 Jul 5th, 2009 12:50 pm
how to use RegexBuddy? can you help me.
 
I use TRegExpr v.0.952 and now i want use RegexBuddy, but i can't replace code. Can u help me?
var
  Temp: TStringList;
  Index: Integer;
          regex: TRegExpr;
begin
    Temp:= TStringList.Create();
    regex := TRegExpr.create();
    regex.Expression := '(?m)(?g)^ftp:.+';
  try
    for Index:= 0 to FList.Count - 1 do
    begin
      regex.exec(FList[index]);
      if (regex.Match[0] <> '') and (Temp.IndexOf(regex.Match[0]) = -1) then
        Temp.Add(regex.Match[0]);
          end;
i paste and replase code from RegexBuddy for delphi:
Regex := TPerlRegEx.Create(nil);
Regex.RegEx := '(?m)(?g)^ftp:.+';
Regex.Options := [preMultiLine];
but i've got a error Undeclared identifier: 'exec'

FlamingClaw Jul 6th, 2009 2:25 am
Re: how to use RegexBuddy? can you help me.
 
What about units....?
Do not forget to add TRegExpr into uses section of the unit. :D

MrBaseball34 Jul 6th, 2009 2:46 am
Re: how to use RegexBuddy? can you help me.
 
no. i use:
uses ..., PerlRegEx;

FlamingClaw Jul 6th, 2009 3:26 am
Re: how to use RegexBuddy? can you help me.
 
sorry this regexbuddy thing is new to me but I found a page
http://www.regular-expressions.info/delphi.html

MrBaseball34 Jul 6th, 2009 12:26 pm
Re: how to use RegexBuddy? can you help me.
 
i know this site. and what?
i need a specific example or ... help

FlamingClaw Jul 6th, 2009 4:40 pm
Re: how to use RegexBuddy? can you help me.
 
this is a section from the regexbuddy 3.0 user manual
The regex module provides the standard POSIX functions regcomp() for compiling a regular expression,
regerror() for handling compilation errors, regexec() to run a search using a compiled regex, and
regfree() to clean up a regex you’re done with.
--- --- ---
If you want to retrieve the part of the string that was matched, call the exec() function of the RegExp
object that you created, e.g.: mymatch = myregexp.exec("subject"). This function returns an array.
The zeroth item in the array will hold the text that was matched by the regular expression. The following
items contain the text matched by the capturing parentheses in the regexp, if any. mymatch.length indicates
the length of the match[] array, which is one more than the number of capturing groups in your regular
expression. mymatch.index indicates the character position in the subject string at which the regular
expression matched. mymatch.input keeps a copy of the subject string.

Calling the exec() function also changes the lastIndex property of the RegExp object. It stores the index
in the subject string at which the next match attempt will begin. You can modify this value to change the
starting position of the next call to exec().


All times are GMT -4. The time now is 1:25 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC