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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:54:28+00:00 2026-05-23T16:54:28+00:00

I am using C# regex library to do some text find and replace. I

  • 0

I am using C# regex library to do some text find and replace.

I would like to change the following:

1 -> one

11 -> one one

123 -> one two three

for example, here’s my code to replace ampersand:

        string pattern = "[&]";
        string replacement = " and ";
        Regex rgx = new Regex(pattern);
        string result = rgx.Replace(text, replacement);

Edit
I found some great examples of .NET RegEx on MSDN:

http://msdn.microsoft.com/en-us/library/kweb790z.aspx

  • 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-23T16:54:28+00:00Added an answer on May 23, 2026 at 4:54 pm

    Since you’re specifically asking for a regex, you could do something like this

    var digits = new Dictionary<string, string> { 
       { "0", "zero" },
       { "1", "one" },
       { "2", "two" },
       { "3", "three" },
       { "4", "four" },
       { "5", "five" },
       { "6", "six" },
       { "7", "seven" },
       { "8", "eight" },
       { "9", "nine" }
    };
    
    var text = "this is a text with some numbers like 123 and 456";
    
    text = Regex.Replace(text, @"\d", x => digits[x.Value]);
    

    which will give you

    this is a text with some numbers like onetwothree and fourfivesix
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using ICU 4.0 regex library, I find that the following regex is exhibiting exponential
I have a chunk of text like: Name=Long John Silver;Profession=cook;Hobby=Piracy And using the Boost::regex
I have the following string \Qpipe,name=office1\E And I am using a simplified regex library
Using the following regex with the ExtJS library, the intention is to only allow
I have to validate using regex decimal number between 00.00 to 35.35 with following
How do you retrieve selected text using Regex in C#? I am looking for
After having converted a messed up XML using regex, I now need to change
Using the following text as a sample, I need to be able to extract
I'm using a :regex library (found here ) to select elements that have IDs
I'm having a problem using the Boost library in Dev C++, specifically the regex

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.