473,508 Members | 2,292 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Replace a letter in a string

Suppose that you have a string e.g. "delicious" and an integer e.g. 5. How
to
replace the character at position 5 with next character (in position 6) so
that "delicious" becomes "deliicous" ?

Nov 20 '05 #1
4 1640
NM
I suggest that :

Dim myWord As String = "delicious"

Dim myWordInChar As Char() = myWord.ToCharArray()

Dim tmp As Char = myWordInChar(4)

myWordInChar(4) = myWordInChar(5)

myWordInChar(5) = tmp

myWord = New String(myWordInChar)

"Dinko Deranja" <dd******@public.srce.hr> a écrit dans le message de
news:%2****************@tk2msftngp13.phx.gbl...
Suppose that you have a string e.g. "delicious" and an integer e.g. 5. How
to
replace the character at position 5 with next character (in position 6) so
that "delicious" becomes "deliicous" ?

Nov 20 '05 #2
NM
I suggest that :

Dim myWord As String = "delicious"

Dim myWordInChar As Char() = myWord.ToCharArray()

Dim tmp As Char = myWordInChar(4)

myWordInChar(4) = myWordInChar(5)

myWordInChar(5) = tmp

myWord = New String(myWordInChar)

"Dinko Deranja" <dd******@public.srce.hr> a écrit dans le message de
news:%2****************@tk2msftngp13.phx.gbl...
Suppose that you have a string e.g. "delicious" and an integer e.g. 5. How
to
replace the character at position 5 with next character (in position 6) so
that "delicious" becomes "deliicous" ?

Nov 20 '05 #3
Cor
I go for

dim a as string = "delicious"
dim b as string = a.substring(0,4) & a.substring(3)

Cor
Suppose that you have a string e.g. "delicious" and an integer e.g. 5. How
to
replace the character at position 5 with next character (in position 6) so
that "delicious" becomes "deliicous" ?

Nov 20 '05 #4
Cor
I go for

dim a as string = "delicious"
dim b as string = a.substring(0,4) & a.substring(3)

Cor
Suppose that you have a string e.g. "delicious" and an integer e.g. 5. How
to
replace the character at position 5 with next character (in position 6) so
that "delicious" becomes "deliicous" ?

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
15982
by: Nicolas Bouillon | last post by:
Hi I would like to replace accentuel chars (like "é", "è" or "à") with non accetued ones ("é" -> "e", "è" -> "e", "à" -> "a"). I have tried string.replace method, but it seems dislike...
3
3604
by: Claude Schneegans | last post by:
Hi, I'trying to use a regExp in Javascript to replace any all upper case word in a string by the same word having only its first letter in upper case. This expression detects the words: /()(+)/g...
22
11085
by: Phlip | last post by:
C++ers: Here's an open ended STL question. What's the smarmiest most templated way to use <string>, <algorithms> etc. to turn this: " able search baker search charlie " into this: " able...
3
2677
by: Raed Sawalha | last post by:
I have the following letters; string letters = "a;b;c....to z"; the I need to replace the incoming string which containing letters above with integer 1 i did following for(int...
4
4298
by: jgabbai | last post by:
Hi, What is the best way to white list a set of allowable characters using regex or replace? I understand it is safer to whitelist than to blacklist, but am not sure how to go about it. Many...
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7120
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7323
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7494
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.