Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #25093

Cannot manipulate array produced with string.match

From SteveYoungTbird <stephen.young@chello.at>
Newsgroups comp.lang.javascript
Subject Cannot manipulate array produced with string.match
Date 2014-06-27 09:17 +0200
Organization A noiseless patient Spider
Message-ID <loj5qn$cof$1@dont-email.me> (permalink)

Show all headers | View raw


I have produced an array using:

var arr = [];
arr = string.match(/(?:^| )([a-zäöüß]+)(?= [A-Z])/g);

This works as expected and the array is full and can be seen using
console.log or alert().

The array consists of words which I need to filter, so I am trying to
use .splice to remove unwanted instances of the same word using:

for (var i = arr.length - 1; i >= 0; i--) {
    if (arr[i] === 'jim') {
        arr.splice(i, 1);
    }
}

The for loop doesn't recognize any instances of, for instance, 'jim' in
the array although there are several.

I tried the loop using an array I made myself and it worked fine, ie:

arr = ['jim', 'bob', 'arthur', 'jim', 'fred']

What is it about the array produced by the string.match that I am not
understanding? Any help would be much appreciated.

Back to comp.lang.javascript | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Cannot manipulate array produced with string.match SteveYoungTbird <stephen.young@chello.at> - 2014-06-27 09:17 +0200
  Re: Cannot manipulate array produced with string.match Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-27 10:02 +0000
    Re: Cannot manipulate array produced with string.match SteveYoungTbird <stephen.young@chello.at> - 2014-06-27 20:00 +0200
      Re: Cannot manipulate array produced with string.match Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-27 19:13 +0000
        Re: Cannot manipulate array produced with string.match SteveYoungTbird <stephen.young@chello.at> - 2014-06-27 22:18 +0200
          Re: Cannot manipulate array produced with string.match SteveYoungTbird <stephen.young@chello.at> - 2014-06-27 23:24 +0200
            Re: Cannot manipulate array produced with string.match Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-28 01:07 +0000
              Re: Cannot manipulate array produced with string.match Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-28 01:16 +0000
            Re: Cannot manipulate array produced with string.match Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-06-28 23:53 +0200
              Re: Cannot manipulate array produced with string.match SteveYoungTbird <stephen.young@chello.at> - 2014-06-29 22:24 +0200
                Re: Cannot manipulate array produced with string.match Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-06-29 23:19 +0200
  Re: Cannot manipulate array produced with string.match JJ <jj4public@vfemail.net> - 2014-06-27 19:31 +0700

csiph-web