473,327 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

How to add text before a specific character

7 Nibble
In my project I want to add text before the character I will choose. Could you explain how I can do it?
Sep 22 '21 #1

✓ answered by cactusdata

Use Replace method:

Expand|Select|Wrap|Line Numbers
  1. string input = "This is my sentence.";
  2. string specificCharacter = "e";
  3. string prefix = "x";
  4. string result = input.Replace(specificCharacter, prefix + specificCharacter);
  5.  
  6. Console.WriteLine(input);
  7. Console.WriteLine(result);
  8.  
  9. // Output.
  10. // This is my sentence.
  11. // This is my sxentxencxe.

3 3665
dev7060
633 Expert 512MB
In my project I want to add text before the character I will choose. Could you explain how I can do it?
Elaborate the question (since this has been posted under general).
Sep 22 '21 #2
cactusdata
214 Expert 128KB
Use Replace method:

Expand|Select|Wrap|Line Numbers
  1. string input = "This is my sentence.";
  2. string specificCharacter = "e";
  3. string prefix = "x";
  4. string result = input.Replace(specificCharacter, prefix + specificCharacter);
  5.  
  6. Console.WriteLine(input);
  7. Console.WriteLine(result);
  8.  
  9. // Output.
  10. // This is my sentence.
  11. // This is my sxentxencxe.
Sep 23 '21 #3
Jordan Cooper
7 Nibble
Thank you, it really helped!
Sep 23 '21 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Fuzzyman | last post by:
I want to parse some text and generate an output that is similar but not identical to the input. The string I produce will be of similar length to the input string - but a bit longer. I'm...
0
by: JJ | last post by:
Hi, I have a little, big, boring problem :) I have a utf8 txt file to import in a MySQL db, cause I must create a web-application in PHP for reading this information on-line. I have create...
1
by: Hyrum Mortensen | last post by:
Hi, How do I insert text that contains the ' character into a text column? I'm getting an Incorrect syntax error.
0
by: Olav | last post by:
Resolving character references with C++/Arabica I have an element that looks like this: <PhoneNumber>&lt;NUMBER&gt;</PhoneNumber> I would like to have the content returned as "<NUMBER>". Not...
2
by: Frank | last post by:
Hello, I'm a total newbie on Javascript, and with a lot of help and some copy and paste managed to get things running. On my site: http://home.wanadoo.nl/homepage I use a form from Bravenet....
9
by: Martin Nadoll | last post by:
Hello, I am working on a form-validation script. There is a input-field where you input a float or integer numper (maximum price to output in database-query). But my Cold-Fusion Query...
44
by: shahaba | last post by:
I have a list of texts and I need to find out the number of times each character shows up. Example in the text "76DC4-34" the character '4' shows up twice. Is there a query that for this instance...
4
by: giorgisp | last post by:
I have a file and I want to echo the text from character 2 to 27. How can I do this? Thanks
2
by: darktemp | last post by:
I have a line of characters that need to be separated. One example is like this: 513413;dialog_513413;Sally Mae has some jobs for you.; Three sets of data all split into three groups placed in...
0
by: rjd1 | last post by:
Background: I am using ColdFusion to access an MS-Access database table via SQL. I have a membership list database table with four email address fields (email1, email 2, email3, email4) - all in...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.