Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6920293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:07:44+00:00 2026-05-27T10:07:44+00:00

I would like to capitalize names properly, which in this case means: The first

  • 0

I would like to capitalize names properly, which in this case means:

  • The first letter is capitalized.
  • The first letter after a space is capitalized (‘Van Helsing’, not ‘Van helsing’)
  • The first letter after a dash is capitalized (‘Johnson-Smith’, not ‘Johnson-smith’)
  • No other letters are capitalized.

The first and last requirements are easily handled:

CONCAT(LEFT(name, 1), LOWER(RIGHT(name, LENGTH(name) - 1)))

The others are harder. I’ve written a 54-times-nested REPLACE statement (not by hand of course, I used Excel)

REPLACE(REPLACE(REPLACE(REPLACE(...,' b',' B'),'-b','-B'),' a',' A'),'-a','-A')

but I feel like there must be a more elegant and maintainable solution. Any ideas?

If there’s a built-in function that is similar but not identical to my requirements that would probably be fine.


Edit: This script will only run on names that have lost their capitalization already, so there’s no danger in mis-handling obscure names. Handling apostrophes like spaces and dashes would be nice, though. A glance through the current data shows that many (~30%) of the names have at least one of [-‘ ].

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:07:45+00:00Added an answer on May 27, 2026 at 10:07 am

    The code frustratedwithforms posted does not work correctly…it correctly capitalizes the first and last words in the string and deletes anything in between (if there are > 2). Someone posted a corrected version at the URL he posted…

    (See Matt Cavanaugh’s post on May 15 2009 3:52pm at: http://dev.mysql.com/doc/refman/5.1/en/string-functions.html)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to change case (all caps or capitalize first letter of sentence)
I'd like to capitalize the first letter following a colon or an ? in
i would like to trim file names in batch for eg: From This IsGood
I'm looking for a function to properly capitalize names like McDonald, FitzGerald, MacArthur, O'Lunney's,
I have a <select> element within which I would like to Capitalize the text
I have a string: 'Some_string_to_capitalize' which I would like to transform to 'Some_String_To_Capitalize'. I
Would like to know how to hide an div after a set of css3
I would like to change the following string fgsloiwrthowmwohitjwptpbspdfmjlsihjwslihj to this string FGsloIwrtHowMwoHItJwpTpBspDfmJlsIhJwslIHJ I
I want to standardize a user-supplied string. I'd like the first letter to be
I would like to access profiles table from my Profile model which belongs_to :user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.