Case insensitive String startsWith, contains, endsWith, replaceAll method

Biju bijumaillist at
Sat Feb 16 15:58:49 PST 2013

In most time when user want to search something in a text, he/she
wants to do a case insensitive search.
For example to filter items displayed in list on a page.
Also on other applications, say any word processor, or in page search
in Firefox, IE, Chrome etc.

So can we make the default behavior of new methods String.startsWith,
String.contains, String.endsWith case insensitive?

And to make it case sensitive we should add a third flag parameter matchCase

var startsWith = str.startsWith(searchString [, position [, matchCase] ] );
var contained = str.contains(searchString [, position [, matchCase] ] );
var endsWith = str.endsWith(searchString [, position [, matchCase] ] );

Additionally we should have a String.replaceAll method right now web
developers are using complex logic to achieve the same.
(Again with insensitive search by default.)
String.replace is not helping, as it default to case sensitive and a
one time operation, if the first parameter is not a regular

We could also add String.replaceFirst and String.replaceLast method.

If we dont want change behavior of String.startsWith, String.contains,
String.endsWith to case insensitive.
Can we have another set methods probably named
String.startsWithI, String.containsI, String.endsWithI
(where "I" stands for ignore/insensitive case)


More information about the es-discuss mailing list