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
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
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
On [DATE], "[NAME]" <[ADDRESS]> wrote:
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. At last one good example of using Method Finder, Have you more examples ? Here in Argentina we have a beginners group and we are collecting material for translate to Spanish.
Edgar
Lic. Edgar J. De Cleene wrote:
At last one good example of using Method Finder, Have you more examples ? Here in Argentina we have a beginners group and we are collecting material for translate to Spanish.
Sorry, I don't have a collection of them. Try simple things like
3. 4. 12
to see
3 * 4 --> 12 3 lcm: 4 --> 12
or
'text'. 'TEXT'
to see
'text asUppercase --> 'TEXT'
Typing the arguments and the result doesn't always find what you are looking for, because sometimes there is no one single methd that does what you want. I can't think of a concrete example right now.
More frequently, I enter a method name fragment to find all method names that match. For example, when I want to find methods that return information about instance variables, I type
instance
in the top pane. That returns a lot of methods.
Jim
On [DATE], "[NAME]" <[ADDRESS]> wrote:
Sorry, I don't have a collection of them. Try simple things like
- 12
to see
3 * 4 --> 12 3 lcm: 4 --> 12
or
'text'. 'TEXT'
to see
'text asUppercase --> 'TEXT'
Typing the arguments and the result doesn't always find what you are looking for, because sometimes there is no one single methd that does what you want. I can't think of a concrete example right now.
More frequently, I enter a method name fragment to find all method names that match. For example, when I want to find methods that return information about instance variables, I type
instance
in the top pane. That returns a lot of methods.
Ok , Its a useful info Maybe I should start exercise and do the collection . Thanks
Edgar
On Wed, 30 Mar 2005 07:22:30 -0300, Lic. Edgar J. De Cleene edgardec2001@yahoo.com.ar wrote:
Have you more examples ?
100. 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000.
Sorry, couldn't resist ;)
Here in Argentina we have a beginners group and we are collecting material for translate to Spanish.
So, make it a game - who finds the funniest/most esoteric/... example of a 'Method finder pattern'?
On [DATE], "[NAME]" <[ADDRESS]> wrote:
933262154439441526816992388562667004907159682643816214685929638952175999932299 156089414639761565182862536979208272237582511852109168640000000000000000000000 00.
Sorry, couldn't resist ;)
Here in Argentina we have a beginners group and we are collecting material for translate to Spanish.
So, make it a game - who finds the funniest/most esoteric/... example of a 'Method finder pattern'?
I think nobody could beat this !!
squeak-dev@lists.squeakfoundation.org