Linked Questions

-2 votes
2 answers
962 views

I am currently trying to replace a single character in a string with more than one number. Lets make it quick: replace(string.begin(), string.end(), 'a', '1'); ^ WORKS! ^ replace(string.begin(), ...
Marwan Ansari's user avatar
0 votes
1 answer
425 views

I want to replace all occurrences of '$' with "$$". Currently I am using string::find to check if '$' is present in string or not. then I am using for loop and checking every character if it matches ...
alohamora's user avatar
0 votes
2 answers
161 views

I found a little mistake, when I enter my email, find results that do not match expectations and the result is a symbol '@' turned into '%40', I would like to change the text '%40' became a symbol of ...
kramster's user avatar
-3 votes
1 answer
171 views

I need find all occurrences of sequence: \r\n(some hex number)\r\n and delete this sequences from my string. Hexadecimal number doesn't start with 0x or x. It's just 20bb for example. These ...
ext_zp's user avatar
  • 11
-5 votes
2 answers
138 views

I have a string such as: AAAbbbbbAAA I'd like to remove all the occurances of a pattern AAA to get: bbbbb The pattern can occur anywhere in the string.
Grégoire Borel's user avatar
0 votes
0 answers
134 views

I apologize if this already has been answered but I didn't manage to find a solution on exactly this. I want to find all occurrences of a specific substring in a string and then replace those ...
enheldel's user avatar
1 vote
1 answer
94 views

I started learning C ++ and my task is to replace some characters in the text. Something similar to the template Here are some examples: <h1>Title</h1>$ js $<p>text...</p> ...
user avatar
0 votes
0 answers
101 views

I am trying to write a program that compresses text. For example, it would change aaaa to a^4. For whatever reason, my compiler thinks that I am trying to overload a function when I am not. Here is ...
PresidentGamer's user avatar
0 votes
1 answer
82 views

if I have a string eg 2,4,-1,3,-1, how do I replace all the -1's with the word "wrong"? and how do I remove the comma at the very end? the output has come from an array cout<<array[c]<<"...
user avatar
0 votes
0 answers
57 views

I am trying to replace a string in a vector of structs. struct Song { string artist; string title; string album; double m_price; string year; size_t length; }; vector<Song&...
Dr_Cringe's user avatar
0 votes
0 answers
57 views

I'm trying to replace "\n" with "\n" but I'm not allowed to do it with this function: std::replace(encryptedKey.begin(), encryptedKey.end(), "\n", "\\n"); encryptedKey is a long string. I think I ...
Kuno Heltborg's user avatar
0 votes
1 answer
60 views

The function: void cleanAlbum() removes the token [None] from the album field of the songs that do not have a valid album. I have a vector of Songs called collection and there are strings like string ...
Josh Brown's user avatar
146 votes
21 answers
293k views

How could I replace a substring in a string with another substring in C++, what functions could I use? eg: string test = "abc def abc def"; test.replace("abc", "hij").replace("def", "klm"); //...
Steveng's user avatar
  • 2,475
274 votes
8 answers
151k views

I am new to C++ programming, but I have experience in Java. I need guidance on how to pass objects to functions in C++. Do I need to pass pointers, references, or non-pointer and non-reference values?...
Rakesh K's user avatar
  • 8,555
125 votes
20 answers
397k views

Given a (char *) string, I want to find all occurrences of a substring and replace them with an alternate string. I do not see any simple function that achieves this in <string.h>.
user avatar

15 30 50 per page