I have a string that has multiple standardized substrings (in CAPS) in it, and I'd like to replace those substrings with numbers. For example, I have:
int one = 5; double two = 77.14; double three = 999.67; int four = 2; string template = "some stuff ONE more TWO even more stuff THREE stuff FOUR"; string result = "";
and I want to turn it into this:
int one = 5; double two = 77.14; double three = 999.67; int four = 2; string template = "some stuff 5 more 77.14 even more stuff 999.67 stuff 2"; string result = "";
I know you can use str_replace to accomplish this, but after reading up on it I'm more confused than how I started. I also know I can convert the numbers to strings using a string stream, but that seems like it might be overkill, and I have a feeling I'm missing a simpler solution.
Would anyone mind giving me an example with str_replace of how this could be done, with an explanation, please? All I need is one clearly explained example and then I'll be off and running;
If anyone could give me some help here, I'd really appreciate it.