Biju (2013-02-17T23:56:36.000Z)
On 16 February 2013 20:26, David Bruant <bruant.d at gmail.com> wrote:
> Le 17/02/2013 00:58, Biju a écrit :

> Also, it doesn't seem that hard to implement:
>     String.prototype.startsWithI = function(s){
>         this.match(new RegExp('^'+s, 'i'));
>     }

you also made the common error any developer make
(I am ignoring you have missed the "return" keyword)
If people at es-discuss can make error,
how can you expect an average IT developer get it right.

test this

s="fddfd(ghgg"
new RegExp('^'+s, 'i')

Error!!!


> And sometimes, case-sensitive is what you want.
i agree, that is why I mentioned to add matchCase parameter.
or have startsWithI, containsI, endsWithI instead

>> Additionally we should have a String.replaceAll method right now web
>> developers are using complex logic to achieve the same.
>
>     "aA".replace(/a/ig, 'b'); // 'bb'
> I feel the "i" and "g" flag or regexps aren't that complex. One just needs
> to know about them.

Again you are missing the point that the first parameter of "replace"
at many times have to be a variable with a value which was taken from
user input.


We you cant agree on replaceAll can we atleast bring mozilla
non-standard flags parameter for String.replace as standard.
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/replace#Syntax

You can see a lot of people asking for "replace all occurrences"
https://www.google.com/search?q=javascript+replace+all+occurrences

cheers
Biju
github at esdiscuss.org (2013-07-12T02:26:27.671Z)
David Bruant wrote:
> It doesn't seem that hard to implement:
>
> ```js
> String.prototype.startsWithI = function(s){
>   this.match(new RegExp('^'+s, 'i'));
> }
> ```

you also made the common error any developer make (I am ignoring you have missed the `return` keyword) If people at es-discuss can make error, how can you expect an average IT developer get it right.

test this

```js
s="fddfd(ghgg"
new RegExp('^'+s, 'i')
```

Error!!!


> And sometimes, case-sensitive is what you want.

I agree, that is why I mentioned to add matchCase parameter.
or have startsWithI, containsI, endsWithI instead

> I feel the "i" and "g" flag or regexps aren't that complex. One just needs to know about them.

Again you are missing the point that the first parameter of "replace"
at many times have to be a variable with a value which was taken from
user input.


We you cant agree on replaceAll can we atleast bring mozilla [non-standard flags parameter](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/replace#Syntax) for String.replace as standard.

You can see a [lot of people asking for "replace all occurrences"](https://www.google.com/search?q=javascript+replace+all+occurrences)