Nov 30, 2013 at 5:58pm UTC
I would like to insert some character after each number of my string
I found how to insert before each character, but what I want is :
string str = "12 + 5"
insert ^ after each number
Output = "12^ + 5^"
Thank you for your help
Nov 30, 2013 at 6:05pm UTC
Nov 30, 2013 at 6:07pm UTC
Sorry, but I don't find what I want.
Last edited on
Nov 30, 2013 at 7:33pm UTC
Nov 30, 2013 at 7:36pm UTC
I searched for like 1h30 and I didn't found a solution. All the topic and documentation are about inserting something at a specificate position. I want to add my character after every number. I know it's like "do it for me" and I'm sorry for that, but if you can show me the way, it would be appreciate
Last edited on
Nov 30, 2013 at 7:38pm UTC
Nov 30, 2013 at 7:44pm UTC
i would just write a function to test if it is a digit and then if it is do a while loop to find the next character that isnt a digit and insert the ^ there
Nov 30, 2013 at 7:54pm UTC
This is a very elementary problem, and I understand that you are struggling to go forward. Just giving you the answer, though, won't help.
However, I can give you a significant hint.
Don't insert. Copy.
For each character in your input string, copy it to your output string (appending it).
Once you can simply copy the string, try to figure out when you should append '^'s to your output string too.
Nov 30, 2013 at 8:44pm UTC
That isn't copying, that's searching.