MongoDB currently does not offer the equivalent of a SQL Update statement when you want to change the value of a string to something that is based on the current value. In my case I needed to find spaces and change them to underscores -- something done easily in php with str_replace(), and in MySQL with REPLACE.
If you had a table named foo with a column named "mystr" you could do this sort of update like this:
UPDATE foo SET mystr =REPLACE(mystr,' ','_');
MongoDB does have collection.update() that works with a series of "modifier" operations, but none of them are useful for doing modifications to the current value of a document field when that field is a string.
Again, assuming the collection is named "foo" and the document field is named "mystr"
An existing patch promises to add a new update() modifier but until such a time as it exists, this approach can be used when you need to update strings in a collection, referencing the existing values in the transformation.