Wow, this is really amazing.
You just taught me a new feature of Squeak I didn't know about.
Thanks, Daniel On Mar 29, 2005, at 6:27 PM, Jim Menard wrote:
Daniel,
On Mar 29, 2005, at 6:17 PM, Daniel Salama wrote:
Is there an easy way to do search and replace within a string.
For example, give: 'this is foo test' to replace foo with bar and end up with: 'this is bar test'?
Thanks, Daniel
P.S. Sorry for the simple question but I just can't find the answer. I would assume there is an easy way of doing this other than involving "complicated" logic using String#replaceFrom
I didn't know the answer, either. However, I do know about the Method Finder. (World Menu -> open... -> Method Finder). I opened that and in the top left pane, I typed
'this is foo test'. 'foo'. 'bar'. 'this is bar test'
and hit enter. It found
SequencableCollection>>copyReplaceAll:with: String>>copyReplaceAll:with: Text>>copyReplaceTokens:with:
So, 'this is foo test' copyReplaceAll: 'foo' with: 'bar' does what you want.
Jim
Jim Menard, jimm@io.com, http://www.io.com/~jimm/ "Given infinite time, 100 monkeys could type out the complete works of Shakespeare. Win 98 source code? Eight monkeys, five minutes." -- NullGrey