We help IT Professionals succeed at work.

Create short name from long name

tvtech asked
Medium Priority
Last Modified: 2012-05-11
I need to create an abbreviated 4 character prefix from a list of names. All abbrevations need to be unique.

For example, some of the names are almost identical:

  XYZ Childcare Centre
  XYZ Childcare Centre Pty Ltd
  XYZ Child Care Creche

  Toyota Car Dealer
  Toyota Motor Dealer
  Brisbane Toyota Motor Dealer

How do I go about creating unique 4 character prefixes from any name, similar to others, or not?


Watch Question


How "human readable" do these "abbreviations" need to be?

One obvious solution is to simply assign random 4 digit names to each and generate a table that tells you what abbrev goes with which name.

There's what I would call the "stock ticker" approach, where the 1st name you encounter is given an obvious abbreviation, and as new ones come allong, make a little more cryptic abbreviation (but you still need a chart of what abrev goes to which name).

As an example:
XYZC = XYZ Childcare centre
XYZP = XYZ childcare centre Pty Ltd
XYCC = XYz Childcare Creche
TYCD = ToYota Car Dealer
TYMD = ToYota Motor Dealer
TMDB = Brisbane Toyota Motor Dealer

Are these going to be human assigned abreviations?  Or do you need a computer program to do it for you  (in which case, the Abrevs might be the 1st few characters and a unique number).


As the names are saved to file, they need the human readable abbreviations to be assigned by the software.

Top Expert 2012
Unlock this solution and get a sample of our free trial.
(No credit card required)

Human readable AND assigned by software...  that could be a very complex algorithum... potentally gets into the realm of Artificial Intelegence.  But since you're posting this question under the Visual Basic topic, I assume you're not looking to try to implement something a little simpler.

I'm afraid the simplest thing that I can think of is that when ever a new name is encountered, you prompt a user to key in a new abreviation.  Before accepting the new abreviation, test that it is unique and provide the user a way see a list of current abbreviations.

If you need something more automated, the next level of complexity I can think of is that when ever a new name is encountered, assign a unique number to it.  Periodically (hourly, daily, weekly, etc) you display a list of abreviations that are comprized entirely of numbers (0000 to 9999) and allow a human to override the numeric abreviation.  You then simply to a mass file rename (and update any data) to change the old numeric abreviations to human made/readable abreviations.

After that, you start getting into complex multistep AI algorithums.


Perfect, Graham. Thanks very much! :)
Top Expert 2012

I should have posted an explanation.

If the names is not prefixed with a four-character, uppercase word, a new one is created from the first letters of the existing title, padded with capital As if necessary.

The existing, or new prefix is then checked against any other existing prefixes. If it is the same, a character, starting with the rightmost is moved on to the next letter until it is a Z.

In adding this description, I realise that I should be resetting the previously 'overflowed' character from 'Z' to 'A'  when moving to the next character on the left. However with small datasets, this oversight is theoretical and unlikely to cause any problem.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.