<p>I'm looking for a clean C++ way to parse a string containing expressions wrapped in ${} and build a result string from the programmatically evaluated expressions.</p>

<p>Example:  "Hi ${user} from ${host}" will be evaluated to "Hi foo from bar" if I implement the program to let "user" evaluate to "foo", etc.</p>

<p>The current approach I'm thinking of consists of a state machine that eats one character at a time from the string and evaluates the expression after reaching '}'. Any hints or other suggestions?</p>

<p>Note: boost:: is most welcome! :-)</p>

<p><strong>Update</strong> Thanks for the first three suggestions! Unfortunately I made the example too simple! I need to be able examine the contents within ${} so it's not a simple search and replace. Maybe it will say ${uppercase:foo} and then I have to use "foo" as a key in a hashmap and then convert it to uppercase, but I tried to avoid the inner details of ${} when writing the original question above... :-)</p>

How many evaluation expressions do intend to have?  If it's small enough, you might just want to use brute force.
For instance, if you have a
```
std::map<string, string>
```
that goes from your
```
key
```
to its
```
value
```
, for instance
```
user
```
to
```
Matt Cruikshank
```
, you might just want to iterate over your entire map and do a simple replace on your string of every
```
"${" + key + "}"
```
to its
```
value
```
.