Question: A Knockout newbie here. I've tried to use ko.utils.arrayFilter but it doesn't seem to update when I use it. I'm using the same method I used with arrayForEach so I'm not sure what's wrong here. How can I get this the list to update when using arrayFilter?

JS:

```
function entry(name, category) {
    this.name = ko.observable(name);
    this.category = ko.observable(category);
}

function entriesModel() {
    this.entries = ko.observableArray([]);
    this.filter = function () {
        ko.utils.arrayFilter(this.entries(), function (item) {
            return item.category == 'SciFi';
        });
    };
    this.sort = function () {
        this.entries.sort(function (a, b) {
            return a.category < b.category ? -1 : 1;
        });
    };
}

$(document).ready(function () {
    $.getJSON("entries.php", function (data) {
        entries(data);
    });
    ko.applyBindings(entriesModel());
});

```

HTML:

```
<ul data-bind="foreach: entries">
<li>
    <p data-bind="text: name"></p>

    <p data-bind="text: category"></p>
</li>

```

```
<button data-bind="click: filter">Filter</button>
<button data-bind="click: sort">Sort</button>

```

JSON:

```
[{"id":"1","name":"Iron Man","category":"SciFi"},{"id":"2","name":"Terminator","category":"SciFi"},{"id":"3","name":"The Pianist","category":"Drama"},{"id":"4","name":"The Hangover","category":"Comedy"}]

```

Answer: 
You probably need a no-gready quantifier such as `/(.+?)([fzxrs]+)(.*)/`, or specifying which characters you don't want to move: `/(.[^fzxrs]*)([fzxrs]+)(.*)/`.

This will move the first occurance (except if in first possition) of any wanted character to the end. Your code will move the last one to the end. Tha's why *chafof* fails: it moves the last *f* to the end.
Try following **regex**

```
s/(.+?)([fzxs]|(?<!t|^.)r)(.*)/$1$3$2/g

```

**Short Description**

`(.+?)` will make `+` lazy as desired

`(?<!t|^.)r)` will skip matching `r` which is preceded by `t` or is second character in a string.

Check this in action [here](http://regex101.com/r/iC1qR2) 

**Input**

```
chafo
sasc
chafof
truwowfng
arbcd
abcrd

```

**Output**

```
chaof
sacs
chaoff
truwowngf
arbcd
abcdr

```