473,385 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Splitting text with regular expressions

Hello,

The company I'm working for has taken over a smaller company with a fairly
large customer base. We want to send an email to that customer base
informing them of the takeover but the mailing list is not held in a
database. In fact we've been given it as a Word document.

The individual email addresses are in the format: "Name <address>" e.g.

Bill Gates <bi***@microsoft.com>;

and I've been tasked with the job of splitting the data into its constituent
parts so that we can store them separately in our database.

I wondered if regular expressions might be the most efficient way of doing
this?

Can anyone help me with some guidance on how I might do this?

Thanks,

DJ

Sep 26 '08 #1
2 1320
Hi David,
If you stay in the Word format you will using the Word interop DLL to
move around and capture chunks of text.
Once you have captured a string it doesn't matter much whether you use
regex or string functions to break the string into email address and
name. IMHO.
I prefer regex but am not an expert and rely heavily on Regex Buddy to
construct the expressions.
Given this job is a once only and I dare say you are under a bit of
pressure to get this finished my gut reaction is to get the data into
a csv file if possible. (Word Table -Excel -CSV ) then you can
read it line by line and use string functions to break it up prior to
writing to your database.
hth
Bob

On Fri, 26 Sep 2008 10:24:09 +0100, "David Jackson"
<so*****@somewhere.comwrote:
>Hello,

The company I'm working for has taken over a smaller company with a fairly
large customer base. We want to send an email to that customer base
informing them of the takeover but the mailing list is not held in a
database. In fact we've been given it as a Word document.

The individual email addresses are in the format: "Name <address>" e.g.

Bill Gates <bi***@microsoft.com>;

and I've been tasked with the job of splitting the data into its constituent
parts so that we can store them separately in our database.

I wondered if regular expressions might be the most efficient way of doing
this?

Can anyone help me with some guidance on how I might do this?

Thanks,

DJ
Sep 26 '08 #2
"bob clegg" <cu**********@remooove.xtra.co.nzwrote in message
news:q5********************************@4ax.com...

Hi Bob,

Thanks for the reply.
>Can anyone help me with some guidance on how I might do this?

If you stay in the Word format you will using the Word interop DLL to
move around and capture chunks of text.
No intention to stay in the Word format.
I prefer regex but am not an expert and rely heavily on Regex Buddy to
construct the expressions.
OK, I'll have a look at that for the future.
Given this job is a once only and I dare say you are under a bit of
pressure to get this finished my gut reaction is to get the data into
a csv file if possible. (Word Table -Excel -CSV ) then you can
read it line by line and use string functions to break it up prior to
writing to your database.
In fact, a colleague suggested a much better alternative for this:

string strRawEmail = "Bill Gates <bi***@microsoft.com>";
MailAddress objMailAddress = new MailAddress(strRawEmail);
string strEmailAddress = objMailAddress.Address;
string strDisplayName = objMailAddress.DisplayName;

DJ

Sep 26 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Piet | last post by:
Hello, I have a very strange problem with regular expressions. The problem consists of analyzing the properties of columns of a MySQL database. When I request the column type, I get back a string...
10
by: Angelo Secchi | last post by:
Hi, I have string of numbers and words like ',,,,,,23,,,asd,,,,,"name,surname",,,,,,,\n' and I would like to split (I'm using string.split()) it using comma as separator but I do not want to...
13
by: Eddie | last post by:
I need to validate a text input field. I just want to say if user enters 93101 or 93102 or 93103 or 93105 or 93106 or 93107 or 93108 or 93109 or 93110 or 93111 or 93116 or 93117 or 93118 or...
4
by: Maya | last post by:
Hello Everybody, I have an application that receives a text in this format: Received from john by server.com with ESMTP (SMTPD32-8.05) id AD5258A0142; Sun, 01 Aug 2004 02:54:26 +0100 From:...
20
by: Opettaja | last post by:
I am new to c# and I am currently trying to make a program to retrieve Battlefield 2 game stats from the gamespy servers. I have got it so I can retrieve the data but I do not know how to cut up...
28
by: Materialised | last post by:
Hi all, Just wondering if someone could help me with this little problem I'm having. I have a string value (it actually represents a barcode) which looks like this: 5021378002392 What I...
7
by: Anat | last post by:
Hi, What regex do I need to split a string, using javascript's split method, into words-array? Splitting accroding to whitespaces only is not enough, I need to split according to whitespace,...
8
by: John Pye | last post by:
Hi all I have a file with a bunch of perl regular expressions like so: /(^|)\*(.*?)\*(|$)/$1'''$2'''$3/ # bold /(^|)\_\_(.*?)\_\_(|$)/$1''<b>$2<\/ b>''$3/ # italic bold...
11
by: xyz | last post by:
I have a string 16:23:18.659343 131.188.37.230.22 131.188.37.59.1398 tcp 168 for example lets say for the above string 16:23:18.659343 -- time 131.188.37.230 -- srcaddress 22 ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.