473,434 Members | 1,451 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,434 software developers and data experts.

Manipulation of strings query

Hi,

I'm not too hot on my manipulation of strings. I have a database which
cintains names in the format (Upper case also) LASTNAME, FIRSTNAME

I want to search against that database, but the data on the form to produce
the string will be input in the following format:

Firstname Lastname

So I will need to convert this string in the following ways:

1. Make all uppercase
2. Reverse the position of Firstname & Lastname
3. Add a comma and space between Lastname & Firstname

Basically, so that the string looks exactly as the names will in the
database.

Are there any Maestro's out there that can help me with some code to achieve
this?

Thanks.

Miguel.
Jul 19 '05 #1
6 1451
StressedMonkey wrote:
Hi,

I'm not too hot on my manipulation of strings. I have a database which
What database?? This is always relevant.
cintains names in the format (Upper case also) LASTNAME, FIRSTNAME
Bad idea. These should be in two separate fields.

I want to search against that database,
but the data on the form to
produce the string will be input in the following format:

Firstname Lastname
Bad idea. Users should be instructed to enter the data in the format in
which it appears in the database. Alternatively, you should have two
separate textboxes, one for the first name, and one for the last

So I will need to convert this string in the following ways:

1. Make all uppercase
With most databases, searches are case insensitive, so this step is usually
not necessary.

2. Reverse the position of Firstname & Lastname
3. Add a comma and space between Lastname & Firstname


Now we come to the crux of the matter, illustrating why storing both pieces
of data in a single column is a bad idea.

Nobody has ever come up with a foolproof way of parsing first and last names
from unformatted strings. Sure, most names consist of two words separated by
a space. These are easy. But what about names consisting of 3 or more words.
How would you propose to handle that?

Go back to the beginning: store the two pieces of data in separate fields,
and force the input of the data into two separate textboxes.

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #2
Hi Bob,

The DB is Oracle 8i I think.

I have received the data in an excel spreadsheet which contains the names in
the LASTNAME, FIRSTNAME format and was going to just import it into a table
in the DB. I don't know any way of getting excel to split a cell into 2 so
that I could enter it as 2 fields in a database and I'm certainly not doint
it manually as there are about 2000 rows!

The problem with the string input is that users will not be entering the
data on a form as such, the application performs an LDAP query agains a last
name that they enter. The query then returns the names in the Firstname
(Space) Lastname format............

Cheers.

Miguel.

"StressedMonkey" <mi****@stressedmonkey.net-nospam> wrote in message
news:40***********************@news.dial.pipex.com ...
Hi,

I'm not too hot on my manipulation of strings. I have a database which
cintains names in the format (Upper case also) LASTNAME, FIRSTNAME

I want to search against that database, but the data on the form to produce the string will be input in the following format:

Firstname Lastname

So I will need to convert this string in the following ways:

1. Make all uppercase
2. Reverse the position of Firstname & Lastname
3. Add a comma and space between Lastname & Firstname

Basically, so that the string looks exactly as the names will in the
database.

Are there any Maestro's out there that can help me with some code to achieve this?

Thanks.

Miguel.

Jul 19 '05 #3
Actualy, ignore me, I've found a way of doing it in excel by copying the
data to a text file and imposting it as a csv.

Thanks for the help anyway.
"StressedMonkey" <mi****@stressedmonkey.net-nospam> wrote in message
news:40***********************@news.dial.pipex.com ...
Hi,

I'm not too hot on my manipulation of strings. I have a database which
cintains names in the format (Upper case also) LASTNAME, FIRSTNAME

I want to search against that database, but the data on the form to produce the string will be input in the following format:

Firstname Lastname

So I will need to convert this string in the following ways:

1. Make all uppercase
2. Reverse the position of Firstname & Lastname
3. Add a comma and space between Lastname & Firstname

Basically, so that the string looks exactly as the names will in the
database.

Are there any Maestro's out there that can help me with some code to achieve this?

Thanks.

Miguel.

Jul 19 '05 #4
StressedMonkey wrote:
Hi Bob,

The DB is Oracle 8i I think.

I have received the data in an excel spreadsheet which contains the
names in the LASTNAME, FIRSTNAME format and was going to just import
it into a table in the DB. I don't know any way of getting excel to
split a cell into 2 so that I could enter it as 2 fields in a
database and I'm certainly not doint it manually as there are about
2000 rows!
Sorry, but there is no foolproof method. You will not be able to do this
without some manual intervention to make sure that whatever method you used
handled all the names correctly.
The problem with the string input is that users will not be entering
the data on a form as such, the application performs an LDAP query
agains a last name that they enter. The query then returns the names
in the Firstname (Space) Lastname format............


So modify the query so it returns the names in separate columns ... or is
that out of your control as well?

Here is a simple vbscript way to split a string containing two words
separated by a single space into two strings, each containing a word:

dim str,arSplit,sFirst, sLast, sFormatted

str="FirstName LastName"
arSplit=Split(str," ")
sFirst = arSplit(0)
sLast = arSplit(1)

To combine these and separate them by a comma:

sFormatted = sLast & ", " & sFirst

This will work for most names. The problem arises with names like:

Nicholas Von Helsing
George Hamilton III
Morton Downey, Jr.
Anita Martinez Gonzales
Pamela Sue Anderson

Somebody is going to have to scrutinize the results of any algorithm you
decide to use and verify that the unusual names were handled correctly.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #5
On Tue, 9 Mar 2004 08:40:18 -0500, "Bob Barrows [MVP]"
<re******@NOyahoo.SPAMcom> wrote:
in <e$*************@TK2MSFTNGP12.phx.gbl>
StressedMonkey wrote:
Hi Bob,

The DB is Oracle 8i I think.

I have received the data in an excel spreadsheet which contains the
names in the LASTNAME, FIRSTNAME format and was going to just import
it into a table in the DB. I don't know any way of getting excel to
split a cell into 2 so that I could enter it as 2 fields in a
database and I'm certainly not doint it manually as there are about
2000 rows!

Sorry, but there is no foolproof method. You will not be able to do this
without some manual intervention to make sure that whatever method you used
handled all the names correctly.


What is the problem with parsing names when presented as Last
comma First other than when the comma is omitted?
The problem with the string input is that users will not be entering
the data on a form as such, the application performs an LDAP query
agains a last name that they enter. The query then returns the names
in the Firstname (Space) Lastname format............


So modify the query so it returns the names in separate columns ... or is
that out of your control as well?

Here is a simple vbscript way to split a string containing two words
separated by a single space into two strings, each containing a word:

dim str,arSplit,sFirst, sLast, sFormatted

str="FirstName LastName"
arSplit=Split(str," ")
sFirst = arSplit(0)
sLast = arSplit(1)

To combine these and separate them by a comma:

sFormatted = sLast & ", " & sFirst

This will work for most names. The problem arises with names like:

Nicholas Von Helsing
George Hamilton III
Morton Downey, Jr.
Anita Martinez Gonzales
Pamela Sue Anderson

Somebody is going to have to scrutinize the results of any algorithm you
decide to use and verify that the unusual names were handled correctly.

Bob Barrows


Jul 19 '05 #6
Stefan Berglund wrote:
On Tue, 9 Mar 2004 08:40:18 -0500, "Bob Barrows [MVP]"
<re******@NOyahoo.SPAMcom> wrote:
in <e$*************@TK2MSFTNGP12.phx.gbl>
StressedMonkey wrote:
Hi Bob,

The DB is Oracle 8i I think.

I have received the data in an excel spreadsheet which contains the
names in the LASTNAME, FIRSTNAME format and was going to just import
it into a table in the DB. I don't know any way of getting excel to
split a cell into 2 so that I could enter it as 2 fields in a
database and I'm certainly not doint it manually as there are about
2000 rows!

Sorry, but there is no foolproof method. You will not be able to do
this without some manual intervention to make sure that whatever
method you used handled all the names correctly.


What is the problem with parsing names when presented as Last
comma First other than when the comma is omitted?


None - it's trivial to split on the comma, assuming the data is consistent.
It's going the other way that's the problem ... oh, I see. I misread the
above.

Yes, a macro could easily be written to split the data in the spreadsheet
into the appropriate columns. I'm not fluent with Excel VBA so the OP might
want to ask in an Excel newsgroup. Additionally, once the data is in a
database table, it would be very easy to write a query to split the names
into the appropriate columns. I do not consider it good database design to
store two pieces of data in the same column.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #7

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

Similar topics

2
by: Marcus | last post by:
I am having some problems with trying to perform calculations on time fields. Say I have a start time and an end time, 1:00:00 and 2:30:00 (on a 24 hour scale, not 12). I want to find the...
9
by: Rune | last post by:
Is it best to use double quotes and let PHP expand variables inside strings, or is it faster to do the string manipulation yourself manually? Which is quicker? 1) $insert = 'To Be';...
4
by: Jim McGivney | last post by:
Does anyone know of a concise article that covers string manipulation, such as insert, join, pad, etc. Thanks, Jim
4
by: WaterWalk | last post by:
Hello, I'm currently learning string manipulation. I'm curious about what is the favored way for string manipulation in C, expecially when strings contain non-ASCII characters. For example, if...
3
by: mathewda | last post by:
I'm currently work'n on a project where I'm dynamically generating some HTML as text into a string builder. My ASP page has a <span> tag on it and after I gernerate HTML to my string builder I...
5
by: Joe Nova | last post by:
I'm a C++ noob and I need a little help manipulating strings. I've got a program that takes an expression in the form: "operand1 operator operand2" I'd like to: 1. Find the total length...
5
by: Paul | last post by:
Hi, What would be the best way to remove the following from the start of a string... "A1", "A2, "A3", "A4", "A5", "B1, "B2", "B3", "B4", "B5", "C1", "C2", "C3", "C4", "C5",...
3
by: Nathan Guill | last post by:
I have an interface that works with an Access back-end. I would like to store and/or load user defined query strings per each user (i.e. no user can access another's queries). The idea I had was...
1
by: tourist.tam | last post by:
Hi, I am trying to read a file using a BufferedStream and avoiding at maximum the use of string manipulation. I need now some help understanding on how to use byte array to hold the data and...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.