Hi,

Take a string like the following. Notice it has all sorts of punctuation.

'This is a test-string', he said; the answer was going to be somewhere between 'hard' and 'very hard'.

I need to be able to go through the string and take each word in turn to do some processing to it (replacing the word with another), but leave the punctuation, etc. as it is.

In other words I need to end up with 2 versions of it:

1. the original string
2. another 'output' string, which has all the punctuation in the same places, but with 'processed' words.

Everything I've tried has been hard to do, which either means I'm doing it wrong or it really is hard!

I've been doing things like going along the line, looking for non-alpha characters add them to a variable until I get to an alpha char, process the word, then add the non-alpha chars back to wherever they came from. This has been not very successful.

Is there a better way?

Help appreciated.

Staggers