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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:53:21+00:00 2026-05-24T02:53:21+00:00

I am trying to get a string to have an underscore ‘_’ everywhere on

  • 0

I am trying to get a string to have an underscore ‘_’ everywhere on a case changes in a string to make it more clear to the user. For example if we have a String ‘personal IDnumber’, I want to make it to ‘personal_ID_number’. This is in C#.

Thank you, I appreciate any help, suggestions.

-Sid

  • 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-24T02:53:22+00:00Added an answer on May 24, 2026 at 2:53 am

    Replace on a case change
    You are looking for this (I removed the space before ID, assuming it a typo)

    (?:(?<=[a-z])(?=[A-Z]))|(?:(?<=[A-Z])(?=[a-z]))
    

    It will transform personalIDnumber into personal_ID_number

    See it here on Regexr

    the Lookbehind ((?<=[a-z])) and lookahead ((?=[A-Z])) construction is matching the empty string between a lower case and a uppercase letter (or the other way round in the second part after the pipe |) and replace this with a underscore.

    Replace on a case change with optional whitespace
    If you want to include whitespace in the replace, just include it between the lookarounds

    (?:(?<=[a-z])\s*(?=[A-Z]))|(?:(?<=[A-Z])\s*(?=[a-z]))
    

    It will transform personal IDnumber into personal_ID_number

    See this here on Regexr

    Replace on a case change, but each word starts with an uppercase
    If you say every word starts with an uppercase letter, then you can do this

    (?:(?<=[a-z])(?=[A-Z]))|(?:(?<=[A-Z])(?=[A-Z][a-z]))
    

    This will make from

    PersonalIDNumber
    JustAnotherTest
    OtherWordWithID
    SomeMORETest

    this

    Personal_ID_Number
    Just_Another_Test
    Other_Word_With_ID
    Some_MORE_Test

    See this here on Regexr

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

Sidebar

Related Questions

I'm trying to get the following code working: string url = String.Format(@SOMEURL); string user
I'm trying to get familiar with Collections. I have a String which is my
I have a (hopefully silly) iPhone programming question. I'm trying to get a string
I'm trying to get a string in my call from an array. But have
I am trying to get Numeric from the string. I have string with phone
I have a string formatted like this: item_questions_attributes_abc123_id I'm specifically trying to get the
Im trying to get the last string from a URL for example... http://www.mywebsite/blog/this-post I
I have been trying to get a string between two strings in a line.
I have been spending 2 hours trying to get my path string read from
We are trying to get certain parts of a String. We have the string:

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.