hibbidiji
asked on
email regexp with extras
Hi all. I want to do this:
Give a file open box that will open a standard text file and read it as a stream or something (I'm flexible.) This will be a delimited file that will have the emails from my CoREA mailing list in it. Depending which version of my server I'm using it will either be comma delimited or pipe | delimited. I would love to see a function that would extract the emails here and put them in a tstringlist. Any ideas?
Thanks!
Give a file open box that will open a standard text file and read it as a stream or something (I'm flexible.) This will be a delimited file that will have the emails from my CoREA mailing list in it. Depending which version of my server I'm using it will either be comma delimited or pipe | delimited. I would love to see a function that would extract the emails here and put them in a tstringlist. Any ideas?
Thanks!
ASKER
I can do that... opening a txt file and assigning it to a stream or a tstringlist or whatever. its running through and picking out emails that are comma delimited on each line that i dont know. I suck at regexp and have no experiance at ALL with it on delphi
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That does good with the delimiter, but of maybe 10 things in a line, I have to pick out the email. so I have to go through the templist and do a regular expression check to find the email in the line then pop it into a list.
Try the regex here:
http://www.regular-expressions.info/regexbuddy/email.html
http://www.regular-expressions.info/regexbuddy/email.html
ASKER
My problem is that I dont know how to do regexp in delphi. I've never used it there before. all my regexp experiance is in php
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
OpenDialog1: TOpenDialog;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender
var t:textfile;
s:String;
list:tstrings;
begin
if opendialog1.Execute then
begin
list:=tstringlist.Create;
assignfile(t,opendialog1.F
reset(t);
while not eof(t) do
begin
readln(t,s);
list.Add(s);
end;
// show the list in the memo
memo1.lines:=list;
list.Free;
end;
end;
end.
// DFM FILE
object Form1: TForm1
Left = 192
Top = 107
Width = 696
Height = 480
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 263
Top = 137
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 0
OnClick = Button1Click
end
object Memo1: TMemo
Left = 84
Top = 189
Width = 457
Height = 155
Lines.Strings = (
'Memo1')
TabOrder = 1
end
object OpenDialog1: TOpenDialog
Left = 179
Top = 132
end
end