#257 ✓resolved
Marton Kiss-Albert

Enumerable.grep() not supported fully string pattern

Reported by Marton Kiss-Albert | July 30th, 2008 @ 10:11 PM | in 1.6.1

Enumerable.grep() function not supprted fully string filter. (like gsub - bug 252)

	a=['bad smile :-)','bad smile :-)'];

regexp error....


  grep: function(filter, iterator, context) {
    iterator = iterator ? iterator.bind(context) : Prototype.K;
    var results = [];

    if (Object.isString(filter))
      // filter = new RegExp(filter); <-- OLD VERSION
      filter = new RegExp(RegExp.escape(filter)); // <-- PATCHED VERSION

    this.each(function(value, index) {
      if (filter.match(value))
        results.push(iterator(value, index));
    return results;

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins


Referenced by