String match: is actually javascript string.search()

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

String match: is actually javascript string.search()

Rudi Angela-2
Hi,
Today I needed to split a string into parts using a regular expression, so I browsed the String class to see if there was a method corresponding to the javascript string.match() function. I found a method called match: all right, but it turns out it's not a wrapper for the javascript string function match(), but for search(). I was quite disappointed. So I had to hack the String class and add my own wrapper for the javascript match() function.
Wouldn't it be better to have a match: that wraps javascript match() and a search: (or find: ) that wraps javascript search()?

Rudi
Reply | Threaded
Open this post in threaded view
|

Re: String match: is actually javascript string.search()

Nicolas Petton
Sure, you can report an issue :)

Cheers,
Nico

On Fri, 2011-10-21 at 09:17 -0700, Rudi Angela wrote:

> Hi,
> Today I needed to split a string into parts using a regular
> expression, so I browsed the String class to see if there was a method
> corresponding to the javascript string.match() function. I found a
> method called match: all right, but it turns out it's not a wrapper
> for the javascript string function match(), but for search(). I was
> quite disappointed. So I had to hack the String class and add my own
> wrapper for the javascript match() function.
> Wouldn't it be better to have a match: that wraps javascript match()
> and a search: (or find: ) that wraps javascript search()?
>
>
> Rudi


Reply | Threaded
Open this post in threaded view
|

Re: String match: is actually javascript string.search()

Hannes Hirzel
On 10/21/11, Nicolas Petton <[hidden email]> wrote:

> Sure, you can report an issue :)
>
> Cheers,
> Nico
>
> On Fri, 2011-10-21 at 09:17 -0700, Rudi Angela wrote:
>> Hi,
>> Today I needed to split a string into parts using a regular
>> expression, so I browsed the String class to see if there was a method
>> corresponding to the javascript string.match() function. I found a
>> method called match: all right, but it turns out it's not a wrapper
>> for the javascript string function match(), but for search(). I was
>> quite disappointed. So I had to hack the String class and add my own
>> wrapper for the javascript match() function.
>> Wouldn't it be better to have a match: that wraps javascript match()
>> and a search: (or find: ) that wraps javascript search()?

Rudi,

Yes, I think so. For documentation and compatibility with JavaScript
reason I think it is good to let the JavaScript methods 'shine
through'. On the other side as you report people expect the Smalltalk
string operations to be there.

What Nicolas means is that you get an account on github if you don't
have one and report an issue for
https://github.com/NicolasPetton/amber

--Hannes

>