Hi, i need to do some character replacements in a string.
heres what i have to do, lets say i have the string x= ABCD
i would have to change the character at index 0 to 1, then at 2 to 4, and so on.
i tried to do x.replace(x.charAt(0), x.charAt(1)), but then what happened was if the characters in the string were the same, it replaced all of them by the character at one.
does anyone know how i could do this so this doesn 't happen.
thanks
kate
2 1370
Ok and there's a bit more, if anyone can give me any ideas for it would be great.
ok so i have my string x= "ABCEFGH"
i need to first check if the length is a multiple of 6.
if it is not, i need to add the # character to the end to make it a multiple of 6.
then i need to take the first six, and do the replacements i mentionned above, and then add the number 0 in front of it, since i didn't have to add any # signs to it. then i have to take the second chunk of six, and do the same thing, except i have to add the the number 5 in front, since i added 5#'s to it. any ideas??
im really stuck...
thanks
Ok and there's a bit more, if anyone can give me any ideas for it would be great.
ok so i have my string x= "ABCEFGH"
i need to first check if the length is a multiple of 6.
if it is not, i need to add the # character to the end to make it a multiple of 6.
then i need to take the first six, and do the replacements i mentionned above, and then add the number 0 in front of it, since i didn't have to add any # signs to it. then i have to take the second chunk of six, and do the same thing, except i have to add the the number 5 in front, since i added 5#'s to it. any ideas??
im really stuck...
thanks
You should be able to find everything you need in the specs for the String class.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Vladimir |
last post by:
Method UnicodeEncoding.GetMaxByteCount(charCount) returns charCount * 2.
Method UTF8Encoding.GetMaxByteCount(charCount) returns charCount * 4.
But why that?
Look:
/*
Each Unicode character...
|
by: fake |
last post by:
What exactly does the line:
rGfxOptionsWnd* m_pGfxOptionsWnd;
do?
I have chased this bug and narrowed it down to something that I believe
should not happen and I don't even know what could...
|
by: David Mathog |
last post by:
Every so often one of my fgets() based programs encounters
an input file containing embedded nulls. fgets is happy to
read these but the embedded nulls subsequently cause problems
elsewhere in...
|
by: Ron L |
last post by:
I have a barcode scanner which uses a "keyboard wedge" program so that the
data it scans comes through as if it was typed on a keyboard. I am trying
to have the data in the barcode be displayed in...
|
by: JimmyKoolPantz |
last post by:
IDE: Visual Studio 2005
Language: VB.NET
Fox Pro Driver Version: 9.0.0.3504
Problem: I currently have a problem altering a DBF file. I do not get
any syntax errors when running the program. ...
|
by: zufie |
last post by:
Hi,
I want to specifying a foreign key by altering a table.
First, I create an ORDERS table without specifying a foreign key. Here
is my code:
CREATE TABLE ORDERS
(Order_ID integer,...
|
by: =?Utf-8?B?RXZhbiBSZXlub2xkcw==?= |
last post by:
I am a C++ programmer and have been learning C#. I have constructed a List<>
and I want to iterate over it, altering each string in the list.
In C++, I'd just create an iterator and walk the...
|
by: nexus024 |
last post by:
I am trying to write a program that will continuously sniff eth0 for a specific UDP packet thats being sent to a specific destination IP, alter the data of the packet, and finally transmit it to the...
|
by: dohboy |
last post by:
a kinda newbie here.
I've done a simple little program that reads a text file and counts the number of lines and words.
I had a heck of a time getting it to count properly when I finally discovered...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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,...
|
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...
|
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,...
|
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...
|
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...
|
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,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |