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 330081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:38:53+00:00 2026-05-12T09:38:53+00:00

I admit regex is a strange world and I have not been able to

  • 0

I admit regex is a strange world and I have not been able to really get my head wraped around it. But I have this problem that I believe belongs in the regex world.
i would like to change last names like “o’brian” to “O’Brian” or “macdonald” to “MacDonald” or “who-knew” to “Who-Knew” or “who knew” to “Who Knew”

so far all I have is ….

setCaps("o'brian");
string setCaps(string s)
    {
        string result = Regex.Replace(s, @"\b[a-z]['a-z]\w+", delegate(Match match)
                    {
                        string ch = match.ToString();
                        return char.ToUpper(ch[0]) + ch.Substring(1);
                    });

        return result;

    }

Thanks

  • 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-12T09:38:54+00:00Added an answer on May 12, 2026 at 9:38 am

    Not actually sure this is possible for your Mac…. For example, while macdonald should be MacDonald, Mrs Macey really doesn’t want to be Mrs MacEy. And what if its company names? Smith’s Machinery, doesn’t want to be Smith’s MacHinery!

    The “O” prefix could be problematic also. Consider Mr O’Pera, or Mrs O’Pal!

    The best thing to do with Mac and Mc prefixes is to hold an exception list, which you refer back to. There are only a finite number of these style names!

    The following should help start:
    http://dgmweb.net/genealogy/FGS/Indices/EveryNameIndex-Mc.shtml

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

Sidebar

Related Questions

Well, I hate to admit it but I have a hard time with REGEX,
I am having a hard time getting my head around this regex. What I
I'll admit, I am pretty new with ASP .NET programming and I have been
I admit it's been a while since I've worked with C++, but from what
I must admit it's been a few years since my RegEx class and since
I've been using Eclipse pretty regularly for several years now, but I admit to
I'm really confused as to why my URL dispatcher is not matching this url
RegEx makes my head hurt, can anyone solve this for me? In c# I'm
I have this problem which made my scratch my head: Is there a way
I have to admit, this one has me foxed. Consider this code: use version;

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.